Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. public function reset_password_token($token) {
  2.  
  3.         try {
  4.  
  5.             $user_password_reset_token = UserPasswordResetToken::find_by_token($token);
  6.  
  7.             if($user_password_reset_token->is_expired) {
  8.  
  9.                 throw new Exception('The token is expired');
  10.             }
  11.  
  12.             $user = $user_password_reset_token->user;
  13.  
  14.             $user->reset_password(
  15.                 $this->input->post('new_password'),
  16.                 $this->input->post('new_password_confirm')
  17.             );
  18.  
  19.             $user->force_login();
  20.             $user->save();
  21.  
  22.             $this->session->set_userdata(array(
  23.                 'member_id' => $user->member->id,
  24.                 'OrgID' => $user->member->organisation_id
  25.             ));
  26.  
  27.             $this->session->set_flashdata('alert_success', "Welcome back to the ".$user->member->organisation->name." Academy. Your password has been successfully reset!");
  28.             redirect('/dashboard/');
  29.  
  30.             $user_password_reset_token->is_expired = 1;
  31.  
  32.             catch (Exception $e) {
  33.  
  34.             $this->session->set_flashdata(
  35.                 'alert_error',
  36.                 $e->getMessage()
  37.             );
  38.  
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement