Laravel 5.2 - Auth: display custom error messages

前端 未结 2 1702
生来不讨喜
生来不讨喜 2021-01-04 23:26

How can I customize the error messages (such as \"These credentials do not match our records.\") that are displayed upon unsuccessful login/registration without

2条回答
  •  长发绾君心
    2021-01-04 23:53

    You can override getFailedLoginMessage on the AuthController which comes from the AuthenticatesUsers trait

    protected function getFailedLoginMessage()
    {
        return 'what you want here.';
    }
    

    Or not override it and set a lang value for auth.failed. The getFailedLoginMessage method will check for Lang::has('auth.failed') and use that if its available.

    For the actual validation error messages you can override the postLogin and pass your own array of messages to validate, or if you wanted to change them globally you can adjust them in the appropriate lang file in resources/lang/{lang}/validation.php.

提交回复
热议问题