Skip to content

Commit

Permalink
fix route list
Browse files Browse the repository at this point in the history
  • Loading branch information
sashagm committed Sep 11, 2024
1 parent c0f6fc1 commit 4b771e6
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions src/routes/social.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
<?php

use Illuminate\Support\Facades\Route;
use Sashagm\Social\Http\Controllers\AuthController;
use Sashagm\Social\Http\Controllers\LoginController;

$routes = config('socials.routes', []);

Route::group(['middleware' => ['web', 'guest'], 'prefix' => config('socials.admin_prefix')], function () use ($routes) {

Route::get($routes['auth_login'][0], [LoginController::class, 'redirectToProvider'])
->name($routes['auth_login'][1]);

Route::get($routes['auth_login_callback'][0], [LoginController::class, 'handleProviderCallback'])
->name($routes['auth_login_callback'][1]);

Route::get($routes['auth_login_form'][0], [AuthController::class, 'showLoginForm'])
->name($routes['auth_login_form'][1]);

Route::post($routes['auth_login_form_callback'][0], [AuthController::class, 'login'])
->name($routes['auth_login_form_callback'][1]);
});

Route::group(['middleware' => ['web', 'auth']], function () use ($routes) {

Route::post($routes['social_logout'][0], [LoginController::class, 'logout'])
->name($routes['social_logout'][1]);
});
<?php

use Illuminate\Support\Facades\Route;
use Sashagm\Social\Http\Controllers\AuthController;
use Sashagm\Social\Http\Controllers\LoginController;

$routes = config('socials.routes', []);

Route::group(['middleware' => ['web', 'guest'], 'prefix' => config('socials.admin_prefix')], function () use ($routes) {

if (isset($routes['auth_login'])) {
Route::get($routes['auth_login'][0], [LoginController::class, 'redirectToProvider'])
->name($routes['auth_login'][1]);
}

if (isset($routes['auth_login_callback'])) {
Route::get($routes['auth_login_callback'][0], [LoginController::class, 'handleProviderCallback'])
->name($routes['auth_login_callback'][1]);
}

if (isset($routes['auth_login_form'])) {
Route::get($routes['auth_login_form'][0], [AuthController::class, 'showLoginForm'])
->name($routes['auth_login_form'][1]);
}

if (isset($routes['auth_login_form_callback'])) {
Route::post($routes['auth_login_form_callback'][0], [AuthController::class, 'login'])
->name($routes['auth_login_form_callback'][1]);
}
});

Route::group(['middleware' => ['web', 'auth']], function () use ($routes) {

if (isset($routes['social_logout'])) {
Route::post($routes['social_logout'][0], [LoginController::class, 'logout'])
->name($routes['social_logout'][1]);
}
});

0 comments on commit 4b771e6

Please sign in to comment.