File size: 3,250 Bytes
5f32fbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php

use App\Http\Controllers\Auth\AuthenticatedSessionController;
use App\Http\Controllers\Auth\AuthenticationController;
use App\Http\Controllers\Auth\Google2FAController;
use App\Http\Controllers\Auth\PasswordController;
use App\Http\Controllers\MailController;
use Illuminate\Support\Facades\Route;
use Laravel\Socialite\Facades\Socialite;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;

Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localeSessionRedirect', 'localizationRedirect', 'localeViewPath']], function () {
    Route::middleware('guest')->group(function () {
        Route::get('register', [AuthenticationController::class, 'registerCreate'])
            ->name('register');

        Route::post('register', [AuthenticationController::class, 'registerStore']);

        Route::get('login', [AuthenticatedSessionController::class, 'create'])
            ->name('login');

        Route::post('login', [AuthenticatedSessionController::class, 'store']);

        Route::get('verify-otp', [AuthenticatedSessionController::class, 'verifyOtpCode'])->name('verify-otp');
        Route::post('verify-otp', [AuthenticatedSessionController::class, 'verifyOtp'])->name('verify-otp');

        Route::get('forgot-password', [AuthenticationController::class, 'PasswordResetCreate'])
            ->name('forgot_password');
        Route::post('forgot-password', [MailController::class, 'sendPasswordResetMail']);

        Route::get('forgot-password/retrieve/{password_reset_code}', [MailController::class, 'passwordResetCallback']);
        Route::post('forgot-password/save', [MailController::class, 'passwordResetCallbackSave']);

        //Social Login
        Route::get('/github/redirect', function () {
            return Socialite::driver('github')->redirect();
        })->name('login.github');
        Route::get('/google/redirect', function () {
            return Socialite::driver('google')->redirect();
        })->name('login.google');
        Route::get('/twitter/redirect', function () {
            return Socialite::driver('twitter')->redirect();
        })->name('login.twitter');
        Route::get('/facebook/redirect', function () {
            return Socialite::driver('facebook')->redirect();
        })->name('login.facebook');

        Route::get('/github/callback', [AuthenticationController::class, 'githubCallback']);
        Route::get('/google/callback', [AuthenticationController::class, 'googleCallback']);
        Route::get('/twitter/callback', [AuthenticationController::class, 'twitterCallback']);
        Route::get('/facebook/callback', [AuthenticationController::class, 'facebookCallback']);

        Route::get('2fa/login', [Google2FAController::class, 'login'])->name('2fa.login');
        Route::post('2fa/login', [Google2FAController::class, 'verify']);
    });

    Route::middleware('auth')->group(function () {

        Route::put('password', [PasswordController::class, 'update'])->name('password.update');

        Route::post('logout', [AuthenticatedSessionController::class, 'destroy'])
            ->name('logout');
    });
});

if (file_exists(base_path('routes/custom_routes_auth.php'))) {
    include base_path('routes/custom_routes_auth.php');
}