コード例 #1
0
 /**
  * Update the password of the logged in user
  *
  * @param  String  $username
  * @return Redirect
  */
 public function update($username)
 {
     try {
         $this->changePasswordForm->validate(Input::all());
     } catch (FormValidationException $error) {
         return Redirect::back()->withInput()->withErrors($error->getErrors());
     }
     $user = Account::whereUsername($username)->firstOrFail();
     $old_password = Input::get('old_password');
     $new_password = Input::get('password');
     if (Hash::check($old_password, $user->getAuthPassword())) {
         $user->password = $new_password;
         if (!$user->save()) {
             Flash::error('Error: Failed saving new password!');
         }
         Flash::success('Password has been successfully changed!');
     } else {
         Flash::error('Old password given does not match record!');
     }
     return Redirect::route('accounts.edit', $username);
 }