From 81fcced7d0a73184194ad8d2afa80f94ec12fde5 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 7 Oct 2021 20:49:47 +0200 Subject: [PATCH] wip #4765 @0.25 --- app/Http/Controllers/AdminController.php | 8 ++ app/Http/Controllers/Auth/LoginController.php | 17 +--- app/Models/User.php | 3 + app/Providers/AuthServiceProvider.php | 8 +- composer.lock | 79 +++++++++++++++++-- config/auth.php | 4 +- routes/backpack/base.php | 53 +++++++++++++ 7 files changed, 146 insertions(+), 26 deletions(-) create mode 100644 app/Http/Controllers/AdminController.php create mode 100644 routes/backpack/base.php diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php new file mode 100644 index 0000000..1362ccf --- /dev/null +++ b/app/Http/Controllers/AdminController.php @@ -0,0 +1,8 @@ +middleware('guest')->except('logout'); + return Socialite::driver('google')->redirect(); } } diff --git a/app/Models/User.php b/app/Models/User.php index ce59b28..4956a5c 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,6 +3,7 @@ namespace App\Models; use Cubist\Backpack\Magic\Models\CubistMagicAuthenticatable; +use Mpyw\NullAuth\NullAuthenticatable; class User extends CubistMagicAuthenticatable { @@ -11,4 +12,6 @@ class User extends CubistMagicAuthenticatable 'singular' => 'utilisateur', 'plural' => 'utilisateurs', 'oneinstance' => false]; + + use NullAuthenticatable; } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index ce74491..bcd9e06 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,10 +2,12 @@ namespace App\Providers; +use Cubist\Socialite\CubistSocialiteAuthServiceProvider; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Gate; +use Mpyw\NullAuth\NullAuthServiceProvider; -class AuthServiceProvider extends ServiceProvider +class AuthServiceProvider extends CubistSocialiteAuthServiceProvider { /** * The policy mappings for the application. @@ -23,8 +25,6 @@ class AuthServiceProvider extends ServiceProvider */ public function boot() { - $this->registerPolicies(); - - // + parent::boot(); } } diff --git a/composer.lock b/composer.lock index f817e05..aca7a08 100644 --- a/composer.lock +++ b/composer.lock @@ -1556,17 +1556,18 @@ "source": { "type": "git", "url": "git://git.cubedesigners.com/cubist_socialite.git", - "reference": "dc421ac208a9e1629c3109d7ee8b75fc97d61ba0" + "reference": "571d10f4238e9aeeb50e64813e774c651b97f333" }, "dist": { "type": "tar", - "url": "https://composer.cubedesigners.com/dist/cubist/socialite/cubist-socialite-dev-master-85af59.tar", - "reference": "dc421ac208a9e1629c3109d7ee8b75fc97d61ba0", - "shasum": "6195f23460211fa0564878e35d4f150ccea3c277" + "url": "https://composer.cubedesigners.com/dist/cubist/socialite/cubist-socialite-dev-master-9de216.tar", + "reference": "571d10f4238e9aeeb50e64813e774c651b97f333", + "shasum": "110ab3717c9b84168d157d58b93f3aa687d2d529" }, "require": { "laravel/framework": "~5.8|^6.0|^7.0|^8.0", "laravel/socialite": "^v5.2.5", + "mpyw/null-auth": "^2.0", "php": ">=7.3.0", "socialiteproviders/google": "^4.1.0", "spatie/laravel-permission": "^4.0" @@ -1576,7 +1577,8 @@ "extra": { "laravel": { "providers": [ - "Cubist\\Socialite\\CubistSocialiteServiceProvider" + "Cubist\\Socialite\\CubistSocialiteServiceProvider", + "Cubist\\Socialite\\CubistSocialiteAuthServiceProvider" ] } }, @@ -1599,7 +1601,7 @@ "cubist", "socialite" ], - "time": "2021-10-07T17:24:38+00:00" + "time": "2021-10-07T18:33:55+00:00" }, { "name": "cubist/util", @@ -4658,6 +4660,71 @@ ], "time": "2021-10-01T21:08:31+00:00" }, + { + "name": "mpyw/null-auth", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/mpyw/null-auth.git", + "reference": "4cfe09067629b8856fc34f82418cb116acd42019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpyw/null-auth/zipball/4cfe09067629b8856fc34f82418cb116acd42019", + "reference": "4cfe09067629b8856fc34f82418cb116acd42019", + "shasum": "" + }, + "require": { + "illuminate/auth": "^6.0 || ^7.0 || ^8.0 || ^9.0", + "illuminate/contracts": "^6.0 || ^7.0 || ^8.0 || ^9.0", + "illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.14", + "mockery/mockery": "^1.3", + "orchestra/testbench": "^6.0", + "php-coveralls/php-coveralls": "^2.1" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Mpyw\\NullAuth\\NullAuthServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Mpyw\\NullAuth\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "mpyw", + "email": "ryosuke_i_628@yahoo.co.jp" + } + ], + "description": "Null Guard for Laravel. Designed for Middleware-based authentication and testing.", + "keywords": [ + "Dummy", + "auth", + "illuminate", + "laravel", + "none", + "nothing", + "null" + ], + "support": { + "issues": "https://github.com/mpyw/null-auth/issues", + "source": "https://github.com/mpyw/null-auth/tree/v2.0.0" + }, + "time": "2021-01-25T08:58:33+00:00" + }, { "name": "mxl/laravel-job", "version": "v1.2.0", diff --git a/config/auth.php b/config/auth.php index d37c8da..cf1003a 100644 --- a/config/auth.php +++ b/config/auth.php @@ -37,7 +37,7 @@ return [ 'guards' => [ 'web' => [ - 'driver' => 'session', + 'driver' => 'null', 'provider' => 'users', ], ], @@ -61,7 +61,7 @@ return [ 'providers' => [ 'users' => [ - 'driver' => 'eloquent', + 'driver' => 'socialitegoogle', 'model' => \App\Models\User::class, ], diff --git a/routes/backpack/base.php b/routes/backpack/base.php new file mode 100644 index 0000000..8fcd27f --- /dev/null +++ b/routes/backpack/base.php @@ -0,0 +1,53 @@ + 'App\Http\Controllers', + 'middleware' => config('backpack.base.web_middleware', 'web'), + 'prefix' => config('backpack.base.route_prefix'), + ], + function () { + // if not otherwise configured, setup the auth routes + if (config('backpack.base.setup_auth_routes')) { + // Authentication Routes... + Route::get('login', 'Auth\LoginController@showLoginForm')->name('backpack.auth.login'); + Route::post('login', 'Auth\LoginController@login'); + Route::get('logout', 'Auth\LoginController@logout')->name('backpack.auth.logout'); + Route::post('logout', 'Auth\LoginController@logout'); + + // Registration Routes... + Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('backpack.auth.register'); + Route::post('register', 'Auth\RegisterController@register'); + + // if not otherwise configured, setup the password recovery routes + if (config('backpack.base.setup_password_recovery_routes', true)) { + Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('backpack.auth.password.reset'); + Route::post('password/reset', 'Auth\ResetPasswordController@reset'); + Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('backpack.auth.password.reset.token'); + Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('backpack.auth.password.email'); + } + } + + // if not otherwise configured, setup the dashboard routes + if (config('backpack.base.setup_dashboard_routes')) { + Route::get('dashboard', 'AdminController@dashboard')->name('backpack.dashboard'); + Route::get('/', 'AdminController@redirect')->name('backpack'); + } + + // if not otherwise configured, setup the "my account" routes + if (config('backpack.base.setup_my_account_routes')) { + Route::get('edit-account-info', 'MyAccountController@getAccountInfoForm')->name('backpack.account.info'); + Route::post('edit-account-info', 'MyAccountController@postAccountInfoForm')->name('backpack.account.info.store'); + Route::post('change-password', 'MyAccountController@postChangePasswordForm')->name('backpack.account.password'); + } + }); -- 2.39.5