{"flag":true,"single":true,"pageTitle":"email verification during register","post":{"id":9,"user_id":"1","slug":"email-verification-during-register-cyjk","title":"email verification during register","body":"<p><strong>1.make account and config .env file<\/strong><\/p>\r\n<p><a href=\"https:\/\/mailtrap.io\/inboxes\/1601388\/messages\">https:\/\/mailtrap.io\/inboxes\/1601388\/messages<\/a><\/p>\r\n<p><strong>2.Configratins<\/strong><\/p>\r\n<p>app\/models\/user.php must contain faceds&nbsp;<\/p>\r\n<pre class=\"language-markup\"><code>use Illuminate\\Contracts\\Auth\\MustVerifyEmail;\r\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\r\nuse Illuminate\\Notifications\\Notifiable;<\/code><\/pre>\r\n<p>also implements user.php<\/p>\r\n<pre class=\"language-markup\"><code>class User extends Authenticatable implements MustVerifyEmail\r\n{\r\n\/\/\r\n}<\/code><\/pre>\r\n<p><strong>Database<\/strong><\/p>\r\n<p>user table must contains <strong>email_verified_at <\/strong>field, check it from database\/migrations\/2014_10_12_000000_create_users_table.php if no found add this field and run command<\/p>\r\n<pre class=\"language-markup\"><code>php artisan migrate<\/code><\/pre>\r\n<p><strong>Routing<\/strong><\/p>\r\n<p>goto routing\/web.php and change this<\/p>\r\n<pre class=\"language-markup\"><code>Auth::routes();\r\nto\r\nAuth::routes(['verify' =&gt; true]);<\/code><\/pre>\r\n<p>Now register a new user and check mailtrap inbox, you will get verification email.<\/p>\r\n<p><strong>How to ristrict user to access homepage before verification<\/strong><\/p>\r\n<pre class=\"language-markup\"><code>Route::get('\/home', [App\\Http\\Controllers\\HomeController::class, 'index'])-&gt;name('home');\r\nto\r\nRoute::get('\/home', [App\\Http\\Controllers\\HomeController::class, 'index'])-&gt;name('home')-&gt;middleware('verified');<\/code><\/pre>\r\n<p>Now you first verify then go to home page,<\/p>\r\n<p><strong>Note:<\/strong><\/p>\r\n<p>All pages are inside <strong>resources\/views\/auth<\/strong> you can modify there<\/p>\r\n<p>&nbsp;<\/p>\r\n<p>To disable verification of email:<br>1. remove all from routes <strong>-&gt;middleware('verified');<\/strong><\/p>\r\n<p>2.&nbsp; Change verify true to null<\/p>\r\n<pre class=\"language-markup\"><code>Auth::routes(['verify' =&gt; true]);\r\nto\r\nAuth::routes();<\/code><\/pre>\r\n<p>3. open app\/models\/user.php and&nbsp; remove<strong> implements MustVerifyEmail<\/strong><\/p>","category_id":"2","is_private":"0","created_at":"2023-03-14T04:16:33.000000Z","updated_at":"2023-03-14T04:16:33.000000Z","category":{"id":2,"user_id":"1","name":"Laravel Core","slug":"laravel-nhyt","parent_id":"1","created_at":"2023-03-14T03:58:27.000000Z","updated_at":"2023-03-20T11:30:50.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"1.make account and config .env file https:\/\/mailtrap.io\/inboxes\/1601388\/messages 2.Configratins app\/models\/user.php must contain faceds&nbsp - email verification during register (Updated: March 14, 2023) - Read more about email verification during register at my programming site [SITE]","categories":[]}