Skip to content

Commit

Permalink
must verifiy email on all routes
Browse files Browse the repository at this point in the history
  • Loading branch information
HijenHEK committed Nov 11, 2023
1 parent 098dfc7 commit 1ce2ec8
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
Route::middleware('throttle:5,1')->post('/verify', [AuthController::class, 'verify'])->name('verify');

Route::middleware('guest')->group(function () {
Route::post('/forgot-password', [PasswordResetController::class , 'send'])->name('password.email');
Route::post('/reset-password', [PasswordResetController::class , 'reset'])->name('password.reset');
Route::post('/forgot-password', [PasswordResetController::class, 'send'])->name('password.email');
Route::post('/reset-password', [PasswordResetController::class, 'reset'])->name('password.reset');
});
Route::middleware('auth:sanctum')->group(function () {
Route::post('/logout', [AuthController::class, 'logout'])->name('logout');
Expand All @@ -40,21 +40,33 @@
]);
})->name('mfa.check');
});
Route::post('/mfa' , [MfaController::class ,'verify'])->name('mfa.verify');
});

Route::middleware(['auth:sanctum', 'mfa', 'verified'])->group(function () {

Route::post('/mfa', [MfaController::class, 'verify'])->name('mfa.verify');
Route::middleware('throttle:5,1')->group(function () {
Route::post('/token', [AuthController::class, 'token'])->name('token');
Route::post('/verify', [AuthController::class, 'verify'])->name('verify');
Route::get('/verify/{id}/{hash}', [ProfileController::class, 'verify'])->name('verification.verify');

});
// email verified middleware
Route::middleware('verified')->group(function () {

// returns verified if user can acceess it
Route::get('/verified', function () {
return response()->json([
'message' => 'verified'
]);
})->name('verified.check');
});
});

Route::middleware(['auth:sanctum', 'mfa', 'verified'])->group(function () {



Route::prefix('profile')->group(function () {
Route::get('/', [ProfileController::class, 'show'])->name('profile.show');
Route::post('/update', [ProfileController::class, 'update'])->name('profile.update');
Route::post('/delete', [ProfileController::class, 'destroy'])->name('profile.destroy');
Route::get('/verify/{id}/{hash}', [ProfileController::class, 'verify'])->name('verification.verify');

Route::get('/picture', [ProfilePictureController::class, 'show'])->name('profile.picture.show');
Route::post('/picture', [ProfilePictureController::class, 'store'])->name('profile.picture.store');
Expand All @@ -75,19 +87,10 @@
Route::delete('/{id}', [AttachmentController::class, 'destroy'])->name('attachments.destroy');
});

// email verified middleware
Route::middleware('verified')->group(function () {

// returns verified if user can acceess it
Route::get('/verified', function () {
return response()->json([
'message' => 'verified'
]);
})->name('verified.check');
});


Route::put('/mfa' , [MfaController::class ,'update'])->name('mfa.update');
Route::put('/mfa', [MfaController::class, 'update'])->name('mfa.update');
// admin middleware group
Route::middleware('admin')->group(function () {

Expand Down

0 comments on commit 1ce2ec8

Please sign in to comment.