App\Http\Controllers\User\UserController::updatePassword PHP Method

updatePassword() public method

update Password
public updatePassword ( Illuminate\Http\Request $request ) : Xpressengine\Presenter\RendererInterface
$request Illuminate\Http\Request
return Xpressengine\Presenter\RendererInterface
    public function updatePassword(Request $request)
    {
        $this->validate($request, ['password' => 'required|confirmed']);
        $result = true;
        $message = 'success';
        $target = null;
        if ($this->user->getAuthPassword() !== "") {
            $credentials = ['id' => $this->user->getId(), 'password' => $request->get('current_password')];
            if (Auth::validate($credentials) === false) {
                $message = '현재 비밀번호가 틀렸습니다.';
                $target = 'current_password';
                $result = false;
            }
        }
        $password = $request->get('password');
        try {
            $this->handler->validatePassword($password);
        } catch (Exception $e) {
            throw new HttpException(Response::HTTP_FORBIDDEN, '비밀번호 보안수준을 만족하지 못했습니다.', $e);
        }
        XeDB::beginTransaction();
        try {
            // save password
            $password = \Hash::make($password);
            $this->users->update($this->user, compact('password'));
        } catch (\Exception $e) {
            XeDB::rollback();
            throw $e;
        }
        XeDB::commit();
        return XePresenter::makeApi(['type' => 'success', 'result' => $result, 'message' => $message, 'target' => $target]);
    }