LoginSignup
6
3

More than 5 years have passed since last update.

laravel5.7 新機能 ユーザ登録時のメールアドレス検証

Posted at

laravel5.7でメールアドレスの検証が機能追加されました
これまでは独自で実装していたので楽になりますね

使い方

User Eloquentに \Illuminate\Contracts\Auth\MustVerifyEmail インターフェースを実装し,Auth::routesの引数を足すだけです

users migrationファイルに email_verified_at カラムが追加されています

class User extends Authenticatable implements MustVerifyEmailContract
{
    use Notifiable, MustVerifyEmail;
    //省略
}
Auth::routes(['verify' => true]);

この状態でユーザ登録を行うと確認メールが届きリンクを踏んで本登録という流れです

ルート保護

認証は、authの場合メールアドレス認証をしていない場合でも見れます
メールアドレス認証が必要なルートはverifiedを使うことで保護できます

参考

実装
https://github.com/sizukutamago/laravel5.7-email-verify/commit/b37c7fe7ee8467a9a5e21fc11f1550f7ee6f3fd3

リリースノート
https://readouble.com/laravel/5.7/ja/releases.html

laravel5.7から404の画面とかフォントとかも変わってますね
実装を追うのはまた今度で

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3