/** * Attempt change password of the user * */ public function doResetPassword() { $input = array('token' => Input::get('token'), 'password' => Input::get('password'), 'password_confirmation' => Input::get('confirm_password')); User::setRules('emailResetPassword'); // By passing an array with the token, password and confirmation if (Confide::resetPassword($input)) { $notice_msg = Lang::get('confide::confide.alerts.password_reset'); return Redirect::action('AuthController@login')->with('notice', $notice_msg); } else { $error_msg = Lang::get('confide::confide.alerts.wrong_password_reset'); return Redirect::action('AuthController@resetPassword', array('token' => $input['token']))->withInput()->with('error', $error_msg); } }
public function putChangePassword() { $user = Auth::user(); $data = Input::all(); if (!$user->canSetPassword()) { return $this->_access_denied(); } User::setRules('changePassword'); if (!Hash::check($data['old_password'], $user->password)) { if (Request::ajax()) { return Response::json($this->change_password_invalid_message, 400); } return Redirect::back()->withErrors($user->validationErrors)->withInput()->with('notification:danger', $this->change_password_invalid_message); } if (!$user->update($data)) { return $this->_validation_error($user); } if (Request::ajax()) { return Response::json($this->set_password_message); } return Redirect::action('UsersController@profile', $user->id)->with('notification:success', $this->set_password_message); }