我正在使用Laravel 5.7电子邮件验证。当我尝试登录时说-dTextVeiw.setOnClickListener(new View.onClickListener() {
@Override
public void onClick(View view){
MediaPlayer mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.tic_sound);
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.start();
}
});
http://joxi.ru/n2YqYJaIo1XGO2
我需要将此消息更改为另一种语言,但找不到更改位置。
在资源/语言中-有验证和其他消息,但找不到此消息。谢谢。
答案 0 :(得分:4)
通知:尚未测试,如果有人对此进行了测试,请告诉我它是否有效。应该,但是我想确定
您将必须实现可使用artisan命令创建的自定义中间件:
php artisan make:middleware EnsureEmailIsVerified
EnsureEmailIsVerified.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Contracts\Auth\MustVerifyEmail;
class EnsureEmailIsVerified
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (! $request->user() ||
($request->user() instanceof MustVerifyEmail &&
! $request->user()->hasVerifiedEmail())) {
return $request->expectsJson()
? abort(403, 'YOUR CUSTOM ERROR HERE')
: Redirect::route('verification.notice');
}
return $next($request);
}
}
您将必须将内核文件中的verified
键映射到新的中间件。
app \ Http \ Kernel.php(在底部向下):
/**
* The application's route middleware.
*
* These middleware may be assigned to groups or used individually.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \App\Http\Middleware\EnsureEmailIsVerified::class, // the changed line
];
好的,所以我想我可能已经为您解决了。
我使用Notepad ++的在文件中查找功能,并扫描了Laravel项目中的所有文件以查找:“您的电子邮件未通过验证”
比赛中有一场比赛:
\vendor\laravel\framework\src\Illuminate\Auth\Middleware\EnsureEmailIsVerified.php
该文件是哪个:
<?php
namespace Illuminate\Auth\Middleware;
use Closure;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Contracts\Auth\MustVerifyEmail;
class EnsureEmailIsVerified
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle($request, Closure $next)
{
if (! $request->user() ||
($request->user() instanceof MustVerifyEmail &&
! $request->user()->hasVerifiedEmail())) {
return $request->expectsJson()
? abort(403, 'Your email address is not verified.')
: Redirect::route('verification.notice');
}
return $next($request);
}
}
我猜测,如果您更改此行:? abort(403, 'Your email address is not verified.')
对于您想要的错误,例如:? abort(403, 'Please, verify your email.')
它将显示该内容。 (如果尝试,请确认这一点。)
此解决方案存在一个小问题。由于您的.gitignore
文件告诉git忽略供应商文件夹,因此在推送时不会将其推送到外部存储库。
您将需要更改.gitignore
文件。我对git非常满意,我真的不知道该怎么做。如果有人知道,请将其添加为评论,我将其添加到答案中。
Laravel更新还将也还原此更改,因此您将不得不重写它,此答案的顶部现在有一个更好的解决方案。
答案 1 :(得分:0)
在您的laravel应用程序“ \ vendor \ laravel \ framework \ src \ Illuminate \ Auth \ Middleware \ EnsureEmailIsVerified.php”中遵循此路径 您会在`
中找到错误消息“您的电子邮件地址未验证”public function handle($request, Closure $next)
{
if (! $request->user() ||
($request->user() instanceof MustVerifyEmail &&
! $request->user()->hasVerifiedEmail())) {
return $request->expectsJson()
? abort(403, 'Your email address is not verified.')
: Redirect::route('verification.notice');
}
return $next($request);
}
答案 2 :(得分:0)
您可以像其他人所说的那样直接覆盖文件,但是当Laravel更新时,该文件将被Composer覆盖。
您应该使用EnsureEmailIsVerified
类的内容创建一个新的Middleware类,并在app/Http/Kernel.php
文件中更改“已验证”中间件的声明:
protected $routeMiddleware = [
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
// change to:
'verified' => \Your\Custom\Middleware::class,
];
您甚至可以使中止消息使用lang文件,以便将来进行更改。