Changeset 3183
- Timestamp:
- 07/21/2008 11:16:54 PM (4 months ago)
- Files:
-
- 1 modified
-
trunk/modules/auth/controllers/auth_demo.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/auth/controllers/auth_demo.php
r2593 r3183 16 16 const ALLOW_PRODUCTION = FALSE; 17 17 18 public function __construct()19 {20 parent::__construct();21 22 // Load auth library23 $this->auth = new Auth;24 }25 26 18 public function index() 27 19 { … … 34 26 $form = new Forge(NULL, 'Create User'); 35 27 36 $form->input('email')->label(TRUE)->rules('required|length[4,32] ');28 $form->input('email')->label(TRUE)->rules('required|length[4,32]|valid_email'); 37 29 $form->input('username')->label(TRUE)->rules('required|length[4,32]'); 38 30 $form->password('password')->label(TRUE)->rules('required|length[5,40]'); … … 42 34 { 43 35 // Create new user 44 $user = new User_Model;36 $user = ORM::factory('user'); 45 37 46 if ( ! $user->username_exists($ this->input->post('username')))38 if ( ! $user->username_exists($form->username->value)) 47 39 { 48 40 foreach ($form->as_array() as $key => $val) … … 52 44 } 53 45 54 if ($user->save() AND $user->add _role('login'))46 if ($user->save() AND $user->add('role', 'login')) 55 47 { 48 Auth::instance()->login($user, $form->password->value); 49 56 50 // Redirect to the login page 57 51 url::redirect('auth_demo/login'); … … 66 60 public function login() 67 61 { 68 if ( $this->auth->logged_in())62 if (Auth::instance()->logged_in()) 69 63 { 70 64 $form = new Forge('auth_demo/logout', 'Log Out'); … … 86 80 87 81 // Attempt a login 88 if ( $this->auth->login($user, $form->password->value))82 if (Auth::instance()->login($user, $form->password->value)) 89 83 { 90 84 echo '<h4>Login Success!</h4>'; … … 106 100 public function logout() 107 101 { 108 // Load auth and logout109 $this->auth->logout(TRUE);102 // Force a complete logout 103 Auth::instance()->logout(TRUE); 110 104 111 105 // Redirect back to the login page
