Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function user_create()
- {
- $user = ORM::factory('user');
- $user->username = "user";
- $this->auth = Auth::instance();
- $user->email = "info@test.com";
- $user->password = $this->auth->hash_password('admin');
- $user->add(ORM::factory('role', 'login'));
- $user->add(ORM::factory('role', 'admin'));
- if ($user->save())
- {
- $this->template->title = "user saved";
- $this->template->content = "user saved";
- }
- }
- $user = $this->input->post('username');
- $password = $this->input->post('password');
- if(!empty($user))
- {
- $find_user = ORM::factory('user')->where('username', $user)->find();
- $username = $find_user->username;
- $this->auth = Auth::instance();
- if($this->auth->login($username, $password))
- {
- $error = "logged in";
- }
- else
- {
- $error = "not logged in at all";
- }
- }
- $this->template->content = new View('admin/login_view');
- $this->template->content->user_info = $username . " " . $password;
- $this->template->title = "Login Admin";
- $this->template->content->bind('error', $error);
- public function user_create()
- {
- $user = ORM::factory('user');
- $user->username = "user";
- $this->auth = Auth::instance();
- $user->email = "info@test.com";
- $user->password = 'admin';
- ...
- public function __set($key, $value)
- {
- if ($key === 'password')
- {
- // Use Auth to hash the password
- $value = Auth::instance()->hash_password($value);
- }
- parent::__set($key, $value);
- }
Add Comment
Please, Sign In to add comment