Reset the given user's password.

@param  ResetCompleteRequest $request
@return \Illuminate\Http\Response
427243
public function postReset(ResetCompleteRequest $request)
    {
        $credentials = $request->only(
            'email', 'password', 'password_confirmation', 'token'
        );

        $response = Password::reset($credentials, function ($user, $password) {
            $this->resetPassword($user, $password);
        });

        switch ($response) {
            case Password::PASSWORD_RESET:
                return redirect($this->redirectPath())->with('status', trans($response));

            default:
                return redirect()->back()
                    ->withInput($request->only('email'))
                    ->withErrors(['email' => trans($response)]);
        }
    }
1314671
public function reset(string $key) : Response
    {
        //is the key empty or does it existe?
        if (empty($key) || !$userData = Users::findFirst(['user_activation_forgot = :key:', 'bind' => ['key' => $key]])) {
            throw new Exception(_('This Key to reset password doesn\'t exist'));
        }

        // Get the new password and the verify
        $newPassword = trim($this->request->getPost('new_password', 'string'));
        $verifyPassword = trim($this->request->getPost('verify_password', 'string'));

        //Ok let validate user password
        $validation = new Validation();
        $validation->add('new_password', new PresenceOf(['message' => _('The password is required.')]));
        $validation->add('new_password', new StringLength(['min' => 8, 'messageMinimum' => _('Password is too short. Minimum 8 characters.')]));

        $validation->add('new_password', new Confirmation([
            'message' => _('Passwords do not match.'),
            'with' => 'verify_password',
        ]));

        //validate this form for password
        $messages = $validation->validate($this->request->getPost());
        if (count($messages)) {
            foreach ($messages as $message) {
                throw new Exception($message);
            }
        }

        // Check that they are the same
        if ($newPassword == $verifyPassword) {
            // Has the password and set it
            $userData->user_activation_forgot = '';
            $userData->user_active = 1;
            $userData->password = Users::passwordHash($newPassword);

            // Update
            if ($userData->update()) {
                //log the user out of the site from all devices
                $session = new Sessions();
                $session->end($userData);

                $this->sendEmail($userData, 'reset');

                return $this->response(_('Congratulations! You\'ve successfully changed your password.'));
            } else {
                throw new Exception(current($userData->getMessages()));
            }
        } else {
            throw new Exception(_('Password are not the same'));
        }
    }
107425
public function updatePassword(UpdateProfilePasswordRequest $request)
    {
        $user = $this->user->find($this->auth->id());

        $credentials = [
            'id'       => $this->auth->id(),
            'email'    => $user->email,
            'password' => $request->old_password,
        ];

        if (! $this->auth->attempt($credentials)) {
            Flash::error(trans('user::messages.invalid old password'));

            return redirect()->back();
        }

        $this->user->update($request->all(), $this->auth->id());

        flash(trans('user::messages.password updated'));

        return redirect()->back();
    }
1273014
public function resetPasswordAction(Request $request, User $user)
    {
        $form = $this->createFormBuilder(null, $this->getDefaultFormOptions($request, $user->getId()))->getForm();

        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $this->get(UserManagerInterface::class)->requestNewPassword($user);
            $this->saveEntity($user);

            if ($request->isXmlHttpRequest()) {
                return array_merge(
                    $this->getViewParameters($request, $form, $user),
                    [
                        'dataId' => $user->getId(),
                        'success' => 1,
                    ]
                );
            }

            return $this->redirectToAction('list');
        }

        return $this->renderAction(
            array_merge(
                $this->getViewParameters($request, $form, $user),
                [
                    'dataId' => $user->getId(),
                ]
            )
        );
    }
1072561
public function reset(Request $request)
    {
        $this->validate($request, [
            'token'    => 'required',
            'email'    => 'required|string|email',
            'password' => 'required|string|min:6|confirmed',
        ]);

        $credentials = $request->only('email', 'password', 'password_confirmation', 'token');

        // response
        $response = Password::broker()->reset($credentials, function ($user, $password) {
            $user->password = bcrypt($password);
            $user->password_updated_at = Carbon::now();
            $user->save();
        });

        switch ($response) {
            case Password::PASSWORD_RESET:
                alert()->success('Success',
                    'Congratulations, try signing in with your new password');

                $this->logLogin($request, 'password-reset');

                return redirect(route('login'));

            default:
                return redirect()
                    ->back()
                    ->withInput($request->only('email'))
                    ->withErrors(['email' => trans($response)]);
        }
    }
645112
public function sendResetLinkEmail(Request $request)
    {
        $this->validateEmail($request);

        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $request->only('email')
        );

        return $response == Password::RESET_LINK_SENT
            ? $this->sendResetLinkResponse($request, $response)
            : $this->sendResetLinkFailedResponse($request, $response);
    }
84726
public function resetPassword(Request $request): Response
    {
        $this->denyAccessUnlessLoggedIn();

        // @todo verify hash and if not valid show error page with message

        if ($request->isMethod(Request::METHOD_POST)) {
            // @todo: update password, login customer and redirect to account and show success message
            return $this->redirectToRoute('frontend.account.home.page', []);
        }

        return $this->renderStorefront('@Storefront/page/account/password-reset/password-reset.html.twig', ['page' => []]);
    }
691228
public function update(PasswordUpdateRequest $request)
    {
        $password = $request->new_password;

        if (Hash::check($request->old_password, Auth::user()->password)) {
            $this->resetPassword(Auth::user(), $password);
            return redirect('user/settings')
                ->with('message', 'Password updated successfully');
        }

        return back()->withErrors(['Password could not be updated']);
    }
658998
public function postReset(Request $request)
    {
        $this->validate($request, [
            'token'         => 'required',
            'email'         => 'required|email',
            'password'      => 'required|confirmed|min:6',
        ]);

        // Here we will attempt to reset the user's password. If it is successful we
        // will update the password on an actual user model and persist it to the
        // database. Otherwise we will parse the error and return the response.
        $response = $this->broker()->reset(
            $this->credentials($request), function ($user, $password) {
                $this->resetPassword($user, $password);
            }
        );

        switch ($response) {
            case Password::PASSWORD_RESET:
                return $this->getResetSuccessResponse('pulsar::passwords.reset');

            default:
                return $this->getResetFailureResponse($request, $response);
        }
    }
961813
public function postReset(Request $request, $code)
    {
        // Validate the form data
        $result = $this->validate($request, [
            'password' => 'required|confirmed|min:6',
        ]);

        // Attempt the password reset
        $result = $this->authManager->resetPassword($code, $request->get('password'));

        if ($result->isFailure()) {
            return $result->dispatch();
        }

        // Return the appropriate response
        return $result->dispatch(route('auth.login.form'));
    }
159532
public function password(Request $request): Response
    {
        $this->denyAccessUnlessLoggedIn();

        if ($request->isMethod(Request::METHOD_POST)) {
            // @todo : send recovery email
            return $this->renderStorefront('@Storefront/page/account/password-reset/hash-sent.html.twig', ['page' => []]);
        }

        return $this->renderStorefront('@Storefront/page/account/password-reset/index.html.twig', ['page' => []]);
    }
98214
public function postReset(Request $request) {

		//get user
		if (!$user = DB::table(config('center.db.users'))->whereNull('deleted_at')->where('email', $request->input('email'))->first()) {
			return redirect()->action('\LeftRight\Center\Controllers\LoginController@getReset')->with([
				'error'=>trans('center::site.password_reset_error')
			]);
		}

		//set new token every time
		$token = Str::random();
		DB::table(config('center.db.users'))->where('id', $user->id)->update(['token'=>$token]);

		//reset link
		$link = URL::action('\LeftRight\Center\Controllers\LoginController@getChange', ['token'=>$token, 'email'=>$user->email]);

		//send reminder email
		Mail::send('center::emails.password', ['link'=>$link], function($message) use ($user)
		{
			$message->to($user->email)->subject(trans('center::site.password_reset'));
		});

		return redirect()->action('\LeftRight\Center\Controllers\LoginController@getReset')->with(['message'=>trans('center::site.password_reset_sent')]);
	}
787404
public function doReset(Request $request)
    {
        $existingReset = Password_reset::where('email', $request->email)
                                        ->where('token', $request->token)
                                        ->first();

        if ($existingReset !== null)
        {
            if ($request->password === $request->input('repeat-password'))
            {
                $user = User::where('email',$request->email)->first();
                $user->password = bcrypt($request->password);
                $user->save();

                $existingReset->delete();

                return redirect()->route('success');
            }
            else
            {
                $request->session()->flash('message', 'De ingevoerde wachtwoorden komen niet overeen.');
                return back()->withInput();
            }
        }
        else
        {
            $request->session()->flash('message', 'Het ingevoerde e-mail adres is onjuist.');
            return back()->withInput($request->except('email'));
        }
    }
384228
public function forgotPassword(Request $request)
    {
        $form = $this->app->form(new PhraseaForgotPasswordForm());
        $service = $this->getRecoveryService();

        try {
            if ('POST' === $request->getMethod()) {
                $form->handleRequest($request);

                if ($form->isValid()) {
                    $data = $form->getData();

                    try {
                        $service->requestPasswordResetToken($data['email'], true);
                    }
                    catch (InvalidArgumentException $ex) {
                        /** @Ignore */
                        $message = $this->app->trans($ex->getMessage());
                        throw new FormProcessingException($message, 0, $ex);
                    }

                    $this->app->addFlash('info', $this->app->trans('phraseanet:: Un email vient de vous etre envoye'));

                    return $this->app->redirectPath('login_forgot_password');
                }
            }
        } catch (FormProcessingException $e) {
            $this->app->addFlash('error', $e->getMessage());
        }

        return $this->render('login/forgot-password.html.twig', array_merge(
            $this->getDefaultTemplateVariables($request),
            [ 'form'  => $form->createView() ]
        ));
    }
983522
public function sendResetLinkEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email']);

        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $request->only('email')
        );

        switch ($response) {
            case Password::RESET_LINK_SENT:
                return response()->json([
                    'success' => true
                ]);

            case Password::INVALID_USER:
            default:
                return response()->json([
                    'success' => false,
                    'message' => 'Invalid user'
                ]);
        }
    }
23063
public function resetPassword()
    {
        $this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
        $this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
        $this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
        $this->post('password/reset', 'Auth\ResetPasswordController@reset')->name('password.update');
    }
873953
public function resetPassword()
    {
        $user = $this->_user;
        $user->new_password = $this->password;
        $user->removePasswordResetToken();

        return $user->save(false);
    }