Changeset 20367 for events

Show
Ignore:
Timestamp:
10/01/08 16:31:50 (6 years ago)
Author:
gen
Message:

added account_controller and session_controller

Location:
events/phpframework/akelos/trunk
Files:
10 added
2 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/akelos/trunk/app/controllers/account_controller.php

    r20269 r20367  
    33class AccountController extends ApplicationController 
    44{ 
    5     var $models = array('User','Sentinel'); 
    6  
    7     function __construct() 
    8     { 
    9         $this->settings = Ak::getSettings('admin'); 
    10     } 
    11  
    12     function index() 
    13     { 
    14         $this->redirectToAction('sign_in'); 
    15     } 
    16  
    17     function sign_in() 
     5    public function signup() 
    186    { 
    197    } 
    208 
    21     function sign_up() 
     9    public function settings() 
    2210    { 
    23         if ($this->Request->isPost() && !empty($this->params['user'])){ 
    24             if($this->User->signUp($this->params['user'])){ 
    25                 $this->flash_options = array('seconds_to_close' => 10); 
    26                 $this->flash['success'] = $this->t('Your account has been successfully created'); 
    27                     $this->redirectToAction('sign_in'); 
    28             } 
    29         } 
    30     } 
    31  
    32     function is_login_available() 
    33     { 
    34         if(!empty($this->params['login'])){ 
    35             $this->User->set('login', $this->params['login']); 
    36             $this->User->validatesUniquenessOf('login'); 
    37             if($this->User->getErrorsOn('login')){ 
    38                 $this->renderText('0'); 
    39                 return ; 
    40             } 
    41         } 
    42         $this->renderText('1'); 
    43     } 
    44  
    45     function logout() 
    46     { 
    47         $this->flash['message'] = $this->t("You have successfully logged out."); 
    48         $this->_perform_logout(); 
    49     } 
    50  
    51     function _perform_logout($redirect = true) 
    52     { 
    53         $this->Sentinel->init($this); 
    54         $this->Sentinel->unsetCurrentUser(); 
    55         if($redirect){ 
    56             $settings = Ak::getSettings('admin'); 
    57             $this->redirectTo(empty($settings['sign_in_url'])? array('action'=>'sign_in') : $settings['sign_in_url']); 
    58         } 
    59     } 
    60  
    61     function password_reminder() 
    62     { 
    63         if($this->Request->isPost()){ 
    64             $this->Sentinel->init($this); 
    65             if($User = $this->User->findFirstBy('email', @$this->params['email'])){ 
    66                 if($this->Sentinel->sendPasswordReminder($User)){ 
    67                     $this->renderAction('password_reminder_sent'); 
    68                 }else{ 
    69                     $this->flash_now['error'] = $this->t('There was an error while trying to send you the instructions to reset your password.'); 
    70                 } 
    71             }else{ 
    72                 $this->flash_now['error'] = $this->t('Account not found'); 
    73             } 
    74         } 
    75  
    76     } 
    77  
    78     function reset_password() 
    79     { 
    80         if($this->User = $this->Sentinel->authenticateWithToken(@$this->params['token'])){ 
    81             $this->token = $this->User->getToken(array('expires' => true, 'single_use' => true)); 
    82             if($this->Request->isPost()){ 
    83                 $this->User->setAttributes($this->params['user']); 
    84                 if($this->User->save()){ 
    85                     $this->flash['message'] = $this->t("You can now login using your user name and password."); 
    86                     $this->_perform_logout(); 
    87                 } 
    88             } 
    89         }else{ 
    90             $this->flash['error'] = $this->t('Invalid or expired authentication URL.'); 
    91             $this->redirectToAction('password_reminder'); 
    92         } 
    93         $this->_perform_logout(false); 
    9411    } 
    9512} 
    96  
    97 ?> 
  • events/phpframework/akelos/trunk/app/controllers/user_controller.php

    r20135 r20367  
    1313            return $this->renderAction('home'); 
    1414        } 
    15     } 
    16  
    17     public function signup() 
    18     { 
    1915    } 
    2016