D
D
Dimon3x2019-10-04 13:34:08
Laravel
Dimon3x, 2019-10-04 13:34:08

How to customize authorization validation?

If you enter the wrong email, it will display auth.failed
How to do what would display an error message?
I did that and it didn't help

protected function validateLogin(Request $request) {
       return Validator::make($request->all(), [
            'email' => 'required|string|email|max:255',
            'password' => 'required|string|min:6',
        ], [
            'email.required' => 'The email is required.',
            'email.email' => 'The email needs to have a valid format.',
            'email.exists' => 'The email is not registered in the system.',
       ]);
    }

@if ($errors->has('email'))
                                    <span class="invalid-feedback" role="alert">
                                      
                                        <strong>{{ $errors->first('email') }}</strong>
                                    </span>
                                @endif

And the registration works.
protected function validator(array $data)
    {
         $messages = [
            'g-recaptcha-response.required' => 'Подтвердите, то что вы не робот.',
            'email.unique' => 'Такой E-mail уже используется.',
            'password' => 'Минимальная длина пароля 8 символов.'
         ];

        return Validator::make($data, [
            '_token' => 'required',
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
            'g-recaptcha-response' => ['required', 'recaptcha']
        ], $messages);
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question