Owl\Http\Controllers\UserController::password PHP Method

password() public method

public password ( UserPasswordRequest $request )
$request Owl\Http\Requests\UserPasswordRequest
    public function password(UserPasswordRequest $request)
    {
        $loginUser = $this->userService->getCurrentUser();
        try {
            $user = $this->userService->getById($loginUser->id);
            if (!$this->authService->checkPassword($user->username, \Input::get('password'))) {
                return \Redirect::back()->withErrors(array('warning' => 'パスワードに誤りがあります。'))->withInput();
            }
            if ($this->authService->attemptResetPassword($user->username, \Input::get('new_password'))) {
                return \Redirect::to('user/edit')->with('status', 'パスワード変更が完了しました。');
            } else {
                return \Redirect::back()->withErrors(array('warning' => 'パスワードリセットに失敗しました。'))->withInput();
            }
        } catch (\Exception $e) {
            return \Redirect::back()->withErrors(['warning' => 'システムエラーが発生したためパスワードリセットに失敗しました。'])->withInput();
        }
    }