Send a reset link to the given user.

@param  \Illuminate\Http\Request $request
@return \Illuminate\Http\RedirectResponse
513076
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 = Password::broker()->sendResetLink($request->only('email'));

        switch ($response) {
            case Password::RESET_LINK_SENT:
                alert()->success('Success!',
                    'Please check your inbox for the email with instructions');

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

                return redirect(route('login'));

            default:
                return redirect()
                    ->back()
                    ->withInput($request->only('email'))
                    ->withErrors(['email' => trans($response)]);
        }
    }
391082
public function sendEmailAction(Request $request)
    {
        $username = $request->request->get('username');

        /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
        $userManager = $this->get('fos_user.user_manager');

        $user = $userManager->findUserByUsernameOrEmail($username);

        $ttl = $this->container->getParameter('fos_user.resetting.retry_ttl');

        if (null !== $user && !$user->isPasswordRequestNonExpired($ttl)) {
            if (!$user->isAccountNonLocked()) {
                return new RedirectResponse($this->get('router')->generate('networking_init_cms_admin_resetting_request'));
            }

            if (null === $user->getConfirmationToken()) {
                /** @var $tokenGenerator TokenGeneratorInterface */
                $tokenGenerator = $this->get('fos_user.util.token_generator');
                $user->setConfirmationToken($tokenGenerator->generateToken());
            }

            $this->sendResettingEmailMessage($user);
            $user->setPasswordRequestedAt(new \DateTime());
            $userManager->updateUser($user);
        }

        return new RedirectResponse($this->generateUrl('networking_init_cms_admin_resetting_check_email', [
            'username' => $username,
        ]));
    }
1142185
protected function sendLoginResponse(Request $request)
    {
        $request->session()->regenerate();

        $this->clearLoginAttempts($request);

        return $this->authenticated($request, $this->guard()->user())
                ?: redirect()->intended($this->redirectPath());
    }
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(),
                ]
            )
        );
    }
255158
public function postReauthenticate(Request $request)
    {
        $this->validate($request, [
            'password' => 'required',
        ]);

        $reauth = new ReauthLimiter($request);

        if (!$reauth->attempt($request->password)) {
            return Redirect::back()
                ->withErrors([
                    'password' => $this->getFailedLoginMessage(),
                ]);
        }

        return Redirect::intended();
    }
1042103
public function resetting(Request $request, EventDispatcherInterface $dispatcher, \Swift_Mailer $mailer, TranslatorInterface $translator)
    {
        // Check Auth
        if ($this->checkAuth()) {
            return $this->redirectToRoute($this->getParameter('pd_user.login_redirect'));
        }

        // Build Form
        $form = $this->createForm($this->getParameter('pd_user.resetting_type'));

        // Handle Form Submit
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            // Get Doctrine
            $em = $this->getDoctrine()->getManager();

            // Find User
            $user = $em->getRepository($this->getParameter('pd_user.user_class'))->findOneBy(['email' => $form->get('username')->getData()]);
            if (null === $user) {
                $form->get('username')->addError(new FormError($translator->trans('security.user_not_found')));
            } else {
                // Create TTL
                if ($user->isPasswordRequestNonExpired($this->getParameter('pd_user.resetting_request_time'))) {
                    $form->get('username')->addError(new FormError($translator->trans('security.resetpw_wait_resendig', ['%s' => $this->getParameter('pd_user.resetting_request_time')])));
                } else {
                    // Create Confirmation Token
                    if (empty($user->getConfirmationToken()) || null === $user->getConfirmationToken()) {
                        $user->createConfirmationToken();
                        $user->setPasswordRequestedAt(new \DateTime());
                    }

                    // Send Resetting Email
                    $emailBody = [
                        'confirmationUrl' => $this->generateUrl('security_resetting_password',
                            ['token' => $user->getConfirmationToken()],
                            UrlGeneratorInterface::ABSOLUTE_URL),
                    ];
                    $this->sendEmail($user, $mailer, 'Account Password Resetting', $emailBody, 'Resetting');

                    // Update User
                    $em->persist($user);
                    $em->flush();

                    // Dispatch Register Event
                    if ($response = $dispatcher->dispatch(UserEvent::RESETTING, new UserEvent($user))->getResponse()) {
                        return $response;
                    }

                    // Render
                    return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resettingSuccess.html.twig', [
                        'sendEmail' => true,
                    ]);
                }
            }
        }

        // Render
        return $this->render($this->getParameter('pd_user.template_path') . '/Resetting/resetting.html.twig', [
            'form' => $form->createView(),
        ]);
    }
447962
public function changeAction(Request $request, $locale)
    {
        if (($token = $this->tokenStorage->getToken()) && 'anon.' !== $token->getUser()) {
            $this->localeManager->setUserLocale($locale);
        }

        $request->setLocale($locale);
        $request->getSession()->set('_locale', $locale);

        return new RedirectResponse(
            $request->headers->get('referer')
        );
    }
155702
private function createRedirectResponse(Request $request)
    {
        $url = $this->loginUrl.'?'.http_build_query([
            'redirect_to' => $request->getUri(),
            'reauth'      => 0,
        ]);

        return RedirectResponse::create($url, 302);
    }
1059511
public function reset(Request $request)
    {
        $this->validate($request, $this->rules(), $this->validationErrorMessages());

        // 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);
            }
        );

        return response()->json(['email' => trans($response)], 200);
    }
633354
public function replaceURLAction(Request $request)
    {
        $response = new JsonResponse();

        $response->setData(['text' => $this->urlHelper->replaceUrl($request->get('text'))]);

        return $response;
    }
745349
public function postReset(Request $request) {

        $this->validate($request, [
            'token'    => 'required',
            'email'    => 'required|email',
            'password' => 'required|confirmed|min:6',
        ]);

        $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));
                return view('usermanagement::frontend.'.$this->frontend_template_name.'.password.password_reset_confirmation', [
                    'title'     => 'Password Reset Confirmed',
                    'email'     => $request->input('email'),
                    'username'  => Auth::user()->name,
                ]);

            default:
                return redirect()->back()
                    ->withInput($request->only('email'))
                    ->withErrors(['email' => trans($response)]);
        }
    }
350853
public function checkEmailAction(Request $request)
    {
        $username = $request->query->get('username');

        if (empty($username)) {
            // the user does not come from the sendEmail action
            return new RedirectResponse($this->generateUrl('networking_init_cms_admin_resetting_request'));
        }

        return $this->render('NetworkingInitCmsBundle:Admin:Security/Resetting/checkEmail.html.twig', [
            'base_template' => $this->get('sonata.admin.pool')->getTemplate('layout'),
            'admin_pool' => $this->get('sonata.admin.pool'),
            'tokenLifetime' => ceil($this->container->getParameter('fos_user.resetting.retry_ttl') / 3600),
        ]);
    }
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);
    }
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'
                ]);
        }
    }
1168688
public function postChange(Request $request) {
		if (!$user = DB::table(config('center.db.users'))->whereNull('deleted_at')->where('email', $request->input('email'))->where('token', $request->input('token'))->first()) {
			return redirect()->action('\LeftRight\Center\Controllers\LoginController@getReset')->with([
				'error'=>trans('center::site.password_change_error')
			]);
		}

		//successfully used reset token, time for it to die
		DB::table(config('center.db.users'))->where('id', $user->id)->update([
			'token'=>null,
			'password'=>Hash::make($request->input('password')),
			'last_login'=>new DateTime,
		]);

		//log you in
		Auth::loginUsingId($user->id, true);
		return redirect()->action('\LeftRight\Center\Controllers\TableController@index')->with('message', trans('center::site.password_change_success'));
	}
603784
public function postLogout (Request $request)
    {
        if ($redirect = $request->getSession ()->get ('post-login-redirect'))
        {
            $request->getSession ()->set ('post-login-redirect', null);
            $request->getSession ()->set ('cancel-login-redirect', null);

            return Response::redirect ($redirect);
        }

        return Response::redirect (URLBuilder::getURL ('/'));
    }
545802
public function changeEmail(Request $request)
    {
        $this->validate(
            $request,
            [
                'email' => 'required|email',
            ]
        );

        if ($request->input('email') == Auth::user()->email) {
            return redirect()->back()->withErrors([
                'email' => trans('mustard::account.email_same'),
            ]);
        }

        if (User::findByEmail($request->input('email'))) {
            return redirect()->back()->withErrors([
                'email' => trans('mustard::account.email_exists'),
            ]);
        }

        // Notify the old email
        Auth::user()->sendEmail(
            trans('mustard::account.email_changed'),
            'mustard::emails.account.email-changed',
            ['new_email' => $request->input('email')]
        );

        Auth::user()->email = $request->input('email');

        if (method_exists('unverify', Auth::user())) {
            Auth::user()->unverify();
        }

        Auth::user()->save();

        return redirect()->back()->withStatus(trans('mustard::account.email_changed'));
    }