-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from GDGAlgiers/dev
Added Email verification
- Loading branch information
Showing
16 changed files
with
276 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\User; | ||
use Illuminate\Auth\Events\Verified; | ||
use Illuminate\Foundation\Auth\EmailVerificationRequest; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Routing\Controller; | ||
|
||
class VerifyEmailController extends Controller | ||
{ | ||
|
||
public function sendVerificationEmail(Request $request) | ||
{ | ||
if ($request->user()->hasVerifiedEmail()) { | ||
return response()->json([ | ||
'success' => false, | ||
'message' => 'email already verified' | ||
], 400); | ||
} | ||
|
||
$request->user()->sendEmailVerificationNotification(); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'message' => 'email verification link has been sent' | ||
]); | ||
} | ||
|
||
public function verify(EmailVerificationRequest $request) | ||
{ | ||
if ($request->user()->hasVerifiedEmail()) { | ||
return response()->json([ | ||
'success' => false, | ||
'message' => 'email already verified' | ||
], 400); | ||
} | ||
|
||
if ($request->user()->markEmailAsVerified()) { | ||
event(new Verified($request->user())); | ||
} | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'message' => 'email has been verified' | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.