Handle the reauthentication request to the application.

@param  \Illuminate\Http\Request  $request
@param  \Orchestra\Foundation\Validations\Account  $validator

@return mixed
767060
public function reauth(Request $request, AccountValidator $validator)
    {
        $validation = $validator->on('reauthenticate')->with($request->only(['password']));

        if ($validation->fails()) {
            return $this->userReauthenticateHasFailedValidation($validation->getMessageBag());
        } elseif (! (new ReauthLimiter($request))->attempt($request->input('password'))) {
            return $this->userHasFailedReauthentication();
        }

        return $this->userHasReauthenticated();
    }
393628
public function validateWith($validator, RequestModel $request)
    {
        if (is_array($validator)) {
            $validator = $this->getValidationFactory()->make($request->all(), $validator);
        }

        if ($validator->fails()) {
            $this->throwValidationException($request->request(), $validator);
        }
    }
1202754
public function validate(Validator $validator)
    {
        $handler = $this->get('metadata')->get('handler');
        if (class_exists($handler)) {
            $handler = new $handler();

            return $handler->validate($this, $validator);
        }
    }
674170
public function validationDefault(Validator $validator)
    {
        $validator
            ->add('id', 'valid', ['rule' => 'numeric'])
            ->allowEmpty('id', 'create')
            ->add('email', 'valid', ['rule' => 'email'])
            ->requirePresence('email', 'create')
            ->notEmpty('email')
            ->add('email', 'unique', ['rule' => 'validateUnique', 'provider' => 'table'])
            ->notEmpty('password');

        $validator->add('new_password', 'custom', [
            'rule' => function ($value, $context) {
                if ($value !== $context['data']['confirm_password']) {
                    return false;
                }
                return true;
            },
            'message' => __('Passwords are not equal!'),
        ]);

        $validator->add('confirm_password', 'custom', [
            'rule' => function ($value, $context) {
                if ($value !== $context['data']['new_password']) {
                    return false;
                }
                return true;
            },
            'message' => __('Passwords are not equal.'),
        ]);


        return $validator;
    }
1089090
protected function failedValidation(Validator $validator): void
    {
        throw new HttpResponseException($this->response(
            $this->formatErrors($validator)
        ));
    }
731088
public static function populateValidator(Validator $validator)
	{
		if (static::$provider === null)
		{
			static::setProvider(new FromArray(true, 'validation'));
		}

		return static::$provider->populateValidator($validator);
	}
35557
public function validationDefault(Validator $validator) {
        $validator
                ->add('id', 'valid', ['rule' => 'numeric'])
                ->allowEmpty('id', 'create')
                ->add('sys_user', 'valid', ['rule' => 'numeric'])
                ->allowEmpty('sys_user')
                ->add('sys_role', 'valid', ['rule' => 'numeric'])
                ->allowEmpty('sys_role')
                ->add('allow', 'valid', ['rule' => 'boolean'])
                ->allowEmpty('allow');

        return $validator;
    }
634905
public function validationDefault(Validator $validator)
    {
        $validator
            ->uuid('id')
            ->allowEmpty('id', 'create');

        $validator
            ->allowEmpty('source');

        $validator
            ->dateTime('trashed')
            ->allowEmpty('trashed');

        return $validator;
    }
431194
public function resend(Request $request)
    {
        $user = Auth::user();

        if ($user->getVerified()) {
            return redirect()->back();
        }

        $response = VerifyEmail::sendVerificationLink($user, function (Message $message) use ($user) {
            $message->subject($user->getVerifyEmailSubject());
        });

        switch ($response) {
            case VerifyEmail::VERIFY_LINK_SENT:
                return redirect()->back()->with('status', trans($response));
        }
    }
288897
public function validationDefault(Validator $validator)
    {
        $validator
            ->integer('id')
            ->allowEmpty('id', 'create');

        $validator
            ->requirePresence('name', 'create')
            ->notEmpty('name');

        $validator
            ->email('email')
            ->allowEmpty('email');

        $validator
            ->allowEmpty('username');

        $validator
            ->allowEmpty('password');

        $validator
            ->boolean('is_blocked')
            ->allowEmpty('is_blocked');

        return $validator;
    }
197781
private function attemptExitUser(Request $request)
    {
        if (null === ($currentToken = $this->tokenStorage->getToken()) || null === $original = $this->getOriginalToken($currentToken)) {
            throw new AuthenticationCredentialsNotFoundException('Could not find original Token object.');
        }

        if (null !== $this->dispatcher && $original->getUser() instanceof UserInterface) {
            $user = $this->provider->refreshUser($original->getUser());
            $switchEvent = new SwitchUserEvent($request, $user, $original);
            $this->dispatcher->dispatch($switchEvent, SecurityEvents::SWITCH_USER);
            $original = $switchEvent->getToken();
        }

        return $original;
    }
423609
public function validationDefault(Validator $validator) {
		$validator
			->integer('id')
			->allowEmpty('id', 'create');

		$validator
			->requirePresence('ip', 'create')
			->notEmpty('ip');

		$validator
			->requirePresence('session_id', 'create')
			->notEmpty('session_id');

		$validator
			->allowEmpty('result');

		$validator
			->dateTime('used')
			->allowEmpty('used');

		return $validator;
	}
86018
protected function failedValidation(Validator $validator)
    {
        if ($this->container['request'] instanceof Request) {
            throw new ValidationHttpException($validator->errors());
        }

        parent::failedValidation($validator);
    }
889255
public function authentication(Request $request)
    {
        try {
            $this->authRepositoryInterface->authenticate($request->all());
        } catch (FormValidationException $e) {
            Flash::error($e->getMessage());

            return redirect()
              ->route('auth.login')
              ->withErrors($e->getErrors());
        } catch (AuthenticationException $e) {
            Flash::error($e->getMessage());

            return redirect()->route('auth.login');
        }

        return redirect()->route('dashboard.index');
    }
583732
public function register(Request $request)
    {
        $validator = $this->validator($request->all());

        if ($validator->fails()) {
            $this->throwValidationException($request, $validator);
        }

        $user = $this->create($request->all());

        $broker = $this->getBroker();

        $credentials = $request->only('email');

        Verification::broker($broker)->sendVerificationLink($credentials, function (Message $message) {
            $message->subject($this->getEmailSubject());
        });

        if (config('verification.verify')) {
            return redirect($this->verificationRedirectPath());
        }

        Auth::guard($this->getGuard())->login($user);

        return redirect($this->redirectPath());
    }
508574
public function validationDefault(Validator $validator)
    {
        return $validator
            ->notEmpty(
                'instance_name',
                __d('wasabi_core', 'Please enter a name for your app.')
            )
            ->notEmpty(
                'instance_short_name',
                __d('wasabi_core', 'Please enter a short name for your app.')
            )
            ->notEmpty(
                'Email__email_sender',
                __d('wasabi_core', 'Please enter an email address.')
            )
            ->notEmpty(
                'Email__email_sender_name',
                __d('wasabi_core', 'Please enter a name for the email sender.')
            )
            ->add('Email__email_sender', 'validEmail', [
                'rule' => 'email',
                'message' => __d('wasabi_core', 'Please enter a valid email address.')
            ])
            ->notEmpty(
                'Login__HeartBeat__max_login_time',
                __d('wasabi_core', 'Please choose a maximum login time.')
            )
            ->add('Login__HeartBeat__max_login_time', 'valid', [
                'rule' => function ($value, $context) {
                    return in_array((int)$value, [900000, 1800000, 2700000, 3600000, 6400000]);
                },
                'message' => __d('wasabi_core', 'Please choose a valid maximum login time.')
            ])
            ->numeric(
                'Auth__max_login_attempts',
                __d('wasabi_core', 'Please enter a number above 0.')
            )
            ->greaterThan(
                'Auth__max_login_attempts',
                0,
                __d('wasabi_core', 'Please enter a number above 0.')
            )
            ->notEmpty(
                'User__has_username',
                __d('wasabi_core', 'Please choose if users have a username.')
            )
            ->notEmpty(
                'User__has_firstname_lastname',
                __d('wasabi_core', 'Please choose if users have a firstname and lastname.')
            )
            ->notEmpty(
                'User__allow_timezone_change',
                __d('wasabi_core', 'Please choose if users may change his timezone.')
            )
            ->notEmpty(
                'User__belongs_to_many_groups',
                __d('wasabi_core', 'Please choose if users may belong to multiple groups.')
            );
    }
1340584
public function addValidation(Validator $validator) {
		/** @var \Captcha\Model\Table\CaptchasTable $Captchas */
		$Captchas = TableRegistry::get('CaptchasValidator', ['class' => 'Captcha.Captchas']);

		$Captchas->setValidator(null, $validator);

		$Captchas->addBehavior('Captcha.Captcha');
		/** @var \Captcha\Model\Behavior\CaptchaBehavior $Captchas */
		$Captchas->addValidation($validator);
	}