Discord-auth
Implement a discord authentication
Demo
You can check a demo here
Disclaimers
- Security concern: I highly suggest to restrict login via discord to your discord guild members (see the guild setting in the discord-auth setting admin panel). Discord allow you to restrict access to your discord guild to people that match some critera (discord call that the verification level). This discord feature will help you to restrict who can register to your Azuriom website and avoid malicious users that could try to register to your website with a fake discord account, an unverified email adress that you shouldn't trust, etc....
- This is the very first release, except bugs. I will do my best to fix them
- I don't recommand to use this plugin with basic registration enabled. I suggest to use either register and login with discord OR basic authentification to avoid confusing your users
Install
Download
Via admin panel
Just go to your admin panel, download and active this plugin.
OR manually
Go to plugin
folder, git clone https://github.com/Over2Craft-mc/discord-auth.git
then run cd discord-auth && composer update
Register a discord app and fill credentials
Register a Discord application here https://discord.com/developers/applications and get client ID and client secret in OAuth2 panel. Fill the "redirects" fields with http://domain.test/discord-auth/callback
Go to plugin's settings and fill
client_id
and client_secret
Add a "login via discord" button in your templates
You might need to add button where user can click to login using discord-auth. Basiclly a login button.
Example with ressources/themes/carbon/view/elements/navbar.blade.php
(usually you can find default login button by searching for route('login')
string)
@guest
<li class="nav-item">
<a class="btn btn-secondary mx-1 my-2" href="{{ route('discord-auth.login') }}">{{ trans('discord-auth::messages.login_via_discord') }}</a>
</li>
@endguest
A more advanced way
You can also use some blade directives hasDiscordLinked
and hasNotDiscordLinked
introduced in version 1.2.0
. Here are a few examples
Examples (those things {{-- blablabla --}}
are just comments to help you, you can remove them)
@plugin('discord-auth') {{-- if plugin discord-auth is enabled --}}
@guest {{-- if user is not authenticated --}}
<a href="{{ route('discord-auth.login') }}">Connect with discord</a>
@endguest
@endplugin
@plugin('discord-auth') {{-- if plugin discord-auth is enabled --}}
@auth {{-- if user is authenticated --}}
@hasNotDiscordLinked {{-- if user hasn't a discord account linked --}}
<a href="{{ route('discord-auth.login') }}">Link your account with Discord</a>
@endhasNotDiscordLinked
@endauth
@endplugin
An easier but less aesthetic way
You can also use the admin panel to add a navigation button, but it may be a bit less aesthetic Admin panel -> Navigation
Test if it works
Try to access http://yourdomain.com/discord-auth
and see if it works