我正在尝试在laravel auth上添加验证步骤,但它给我一个错误Swift_TransportException(530)

时间:2019-05-06 13:46:35

标签: php laravel

我在项目中添加了一个laravel身份验证,现在我试图添加一个验证步骤,以便在用户注册时将其带到要求他们验证电子邮件的页面。我遵循了laravel的添加方式,将以下auth添加到了我的家庭控制器中

$this->middleware('auth');
$this->middleware('verified');

将其添加到控制器后,我修改了对此的Auth路由

Auth::routes(['verify' => true]);

在“我的用户”类中,添加了以下代码

class User extends Authenticatable implements MustVerifyEmail 

仅将实现MustVerifyEmail添加到该类。 在此之后它应该可以工作了,但是我得到了以下几个方面

Swift_TransportException (530)
Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required "

$this->middleware('auth');
$this->middleware('verified');

将其添加到我的控制器后,我修改了我的Auth路由

Auth::routes(['verify' => true]);

在“我的用户”类中,添加了以下代码

class User extends Authenticatable implements MustVerifyEmail 

仅将实现MustVerifyEmail添加到该类。 在此之后,它应该可以工作了,但是我得到了以下几个方面

Swift_TransportException (530)
Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required "

这是我的User类

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

这是我的家庭控制器

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
        $this->middleware('verified');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        return view('home');
    }
}

我希望用户注册时可以使用需要他们验证电子邮件的页面。

0 个答案:

没有答案