feat(auth): add Discord auth boilerplate
This commit is contained in:
parent
0b0a40460c
commit
1f08ea12c0
@ -38,10 +38,6 @@ DB_DATABASE=laravel
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
# Bot token for the Discord notification integration.
|
||||
# Create an application & bot here: https://discord.com/developers/applications
|
||||
DISCORD_BOT_TOKEN=
|
||||
|
||||
RECAPTCHA_SITE_KEY=
|
||||
RECAPTCHA_PRIVATE_KEY=
|
||||
RECAPTCHA_VERIFY_URL="https://www.google.com/recaptcha/api/siteverify"
|
||||
@ -53,6 +49,10 @@ MOJANG_API_URL="https://api.mojang.com"
|
||||
IPGEO_API_KEY=""
|
||||
IPGEO_API_URL="https://api.ipgeolocation.io/ipgeo"
|
||||
|
||||
DISCORD_CLIENT_ID=
|
||||
DISCORD_CLIENT_SECRET=
|
||||
DISCORD_BOT_TOKEN=
|
||||
|
||||
ARCANEDEV_LOGVIEWER_MIDDLEWARE=web,auth,can:admin.maintenance.logs.view
|
||||
|
||||
RELEASE=0.8.0
|
||||
|
@ -109,10 +109,12 @@ class LoginController extends Controller
|
||||
}
|
||||
|
||||
public function discordRedirect() {
|
||||
return Socialite::driver('discord')->redirect();
|
||||
return Socialite::driver('discord')
|
||||
->scopes(['email', 'guilds.join', 'guilds.members.read', 'guilds'])
|
||||
->redirect();
|
||||
}
|
||||
|
||||
public function discordCallback() {
|
||||
// TODO;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
'App\Events\UserBannedEvent' => [
|
||||
'App\Listeners\OnUserBanned',
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@
|
||||
"laravel-notification-channels/pusher-push-notifications": "^3.0",
|
||||
"laravel/framework": "^9.0",
|
||||
"laravel/slack-notification-channel": "^2.0",
|
||||
"laravel/socialite": "^5.2",
|
||||
"laravel/socialite": "^5.5",
|
||||
"laravel/tinker": "^2.0",
|
||||
"laravel/ui": "^3.0",
|
||||
"mcamara/laravel-localization": "^1.7",
|
||||
|
12
composer.lock
generated
12
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "1646b8b9400b69e8dd1b83e38b1b77e5",
|
||||
"content-hash": "9d78d96466ddbdc75d3952615e00aafc",
|
||||
"packages": [
|
||||
{
|
||||
"name": "almasaeed2010/adminlte",
|
||||
@ -2488,16 +2488,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/socialite",
|
||||
"version": "v5.5.1",
|
||||
"version": "v5.5.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/socialite.git",
|
||||
"reference": "9b96dfd69e9c1de69c23205cb390550bc71c357e"
|
||||
"reference": "68afb03259b82d898c68196cbcacd48596a9dd72"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/socialite/zipball/9b96dfd69e9c1de69c23205cb390550bc71c357e",
|
||||
"reference": "9b96dfd69e9c1de69c23205cb390550bc71c357e",
|
||||
"url": "https://api.github.com/repos/laravel/socialite/zipball/68afb03259b82d898c68196cbcacd48596a9dd72",
|
||||
"reference": "68afb03259b82d898c68196cbcacd48596a9dd72",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2553,7 +2553,7 @@
|
||||
"issues": "https://github.com/laravel/socialite/issues",
|
||||
"source": "https://github.com/laravel/socialite"
|
||||
},
|
||||
"time": "2022-02-07T16:08:19+00:00"
|
||||
"time": "2022-03-10T15:26:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/tinker",
|
||||
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('discord_token')->after('remember_token');
|
||||
$table->string('discord_refresh_token')->after('discord_token');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('discord_token', 'discord_refresh_token');
|
||||
});
|
||||
}
|
||||
};
|
@ -77,5 +77,16 @@ body {
|
||||
.login-card-footer-nav a {
|
||||
font-size: 14px;
|
||||
color: #919aa3; }
|
||||
.btn-discord {
|
||||
color: #FFFFFF;
|
||||
background-color: #5865f2;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.btn-discord:hover {
|
||||
border-color: #5865f2;
|
||||
border-width: 1px;
|
||||
background-color: #FFFFFF !important;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=login.css.map */
|
||||
|
@ -45,6 +45,10 @@
|
||||
<input type="checkbox" name="remember" id="remember" />
|
||||
</div>
|
||||
<input name="login" id="login" class="btn btn-block login-btn mb-4" type="submit" value="{{__('Sign in')}}">
|
||||
<p class="text-center">{{ __('OR') }}</p>
|
||||
<div class="social-login">
|
||||
<a class="btn btn-block mb-4 btn-discord" href="{{ route('discordRedirect') }}"><i class="fa-brands fa-discord"></i> Continue with Discord</a>
|
||||
</div>
|
||||
</form>
|
||||
<a href="{{ route('password.request') }}" class="forgot-password-link">{{__('Forgot password?')}}</a>
|
||||
<p class="login-card-footer-text">{{__("Don't have an account?")}} <a href="{{ route('register') }}" class="text-reset">{{__('Sign up here')}}</a></p>
|
||||
|
@ -9,6 +9,7 @@
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/4.8.95/css/materialdesignicons.min.css">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" />
|
||||
<script src="https://kit.fontawesome.com/2d0b1aecfa.js" crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="/css/login.css">
|
||||
</head>
|
||||
|
||||
|
@ -78,10 +78,10 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo
|
||||
->name('verify2FA');
|
||||
|
||||
|
||||
Route::get('/auth/redirect/discord', [LoginController::class, 'discordRedirect'])
|
||||
Route::get('/redirect/discord', [LoginController::class, 'discordRedirect'])
|
||||
->name('discordRedirect');
|
||||
|
||||
Route::get('/auth/callback/discord', [LoginController::class, 'discordCallback'])
|
||||
Route::get('/callback/discord', [LoginController::class, 'discordCallback'])
|
||||
->name('discordCallback');
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user