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



rodnicho
rodnicho

Ca serai un plus d'avoir le tag de discord sur la page profil pour tous, un moyen de délink un joueur par la page admin au cas ou :D

October 29, 2021 at 12:50 AM
_voltis
_voltis

edit: Tout fonctionne maintenant ! Ça a été très bien expliqué et documenté :) Merci à toi !

August 31, 2021 at 10:56 AM
magrigri
magrigri

_voltis, Pour le premier point c'est fait. Pour le deuxième point c'est fait aussi, mais ce sera à toi d'ajouter les boutons manuellement https://github.com/magrigry/discord-auth/releases/tag/1.2.0

August 30, 2021 at 12:09 PM
_voltis
_voltis

Il faudrait préciser qu'il faut rajouter en redirect_uri: https://domaine.com/discord-auth/callback Les comptes sont créés avec l'ID comme nom, et non le pseudo Il ne manque plus qu'un bouton pour associer son discord à un compte déjà existant ^^ !

August 29, 2021 at 10:49 AM

Download

Information

  • Author: magrigri
  • Type: Plugin
  • Version: 1.2.0
  • Downloads: 559
  • Released: August 28, 2021 at 10:54 PM
  • Updated: September 5, 2021 at 6:59 PM
Support GitHub
From the same author