Git Product home page Git Product logo

larascord's Introduction

I'm Jakye

Full-stack Web Developer from Romania

Backend

Frontend


Personal Projects

PHP

Larascord - Larascord is a package that allows you to authenticate users in your Laravel application using Discord.

Snowflake - Snowflake is a package for Laravel that allows Twitter's 64 bit snowflake to be used as primary identifier for models.

Laravel-Shell - Laravel-Shell adds a terminal interface to your web application, allowing you to run shell commands directly from your browser.

JavaScript

SteamIdler - Steam Idler is a very light idling script, built in Node.js, for boosting playtime on Steam, without using computer resources.

Python

Instaloader - Instaloader is a wrapper of instaloader/instaloader (a tool to download pictures (or videos) along with their captions and other metadata from Instagram) that aims to make it easier to use in a convenient and user-friendly way.

C#

XAMPPFixer - XAMPP Fixer is a script created in C# which fixes the common "Error: MySQL shutdown unexpectedly." error from XAMPP.


snake

larascord's People

Contributors

damofd avatar jakyeru avatar tfwisaac avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

larascord's Issues

[BUG] Roles column not filled

Describe the bug
On a clean installation following the installation guide on the documentation, the roles column stays empty. I would like to know which roles a user has on the Discord server.

To Reproduce
Steps to reproduce the behavior:

  1. Create a clean installation of Larascord following the official documentation;
  2. Log in to your new Laravel application;
  3. The roles column is empty.

Expected behavior
I would like the roles column to be filled with the users roles (or role ids).

Screenshots/Videos

Desktop (please complete the following information):

  • OS: Windows 11
  • Google Chrome 116.0.5845.111 (Officiële build) (64-bits)
  • Laravel 10.21.0
  • PHP 8.1.22

Additional context

[FEATURE] Discord guild specific username

For every discord guild you can set a specific username. By default you have not set such a username, but it is possible to set this.

So i request to implement a new colum in the user table with this username. You can do it like the roles colum. A JSON object with each guild and the username. If its not set, then there should be NULL.

My Example:

{ "123456789": "Guild-specific-username", "987654321" NULL }

[BUG] No scopes where provided

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Install Laravel: curl -s https://laravel.build/main-app| bash then cd main-app
  2. Edit .env for the mysql data
  3. Install Larascord composer require jakyeru/larascord & php artisan larascord:install
  4. CLIENT ID and CLIENT SECRET:
    image
  5. See error
    image

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Browser + Version: Brave
  • Laravel Version: v8.79.0
  • PHP Version: v8.0.14

Additional context
I did change at the end
APP_URL=https://exi.srpeter.com/
image

[BUG] Logout route error

Describe the bug
The GET method is not supported for route logout. Supported methods: POST.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'youtsite.com/logout'
  2. See error

Expected behavior
You should logout from the dashbaord.

Desktop (please complete the following information):

  • OS: [Windows 10]
  • Browser + Version [Chrome 115.0.5790.171 Official 64-bi Release]
  • Laravel Version [v10.2.5]
  • PHP Version [8.0.6]

[BUG] Re-Login via Discord

Registering and saving to the database works without problems but as soon as you log out to log in again, you get
{"larascord_message":"There was an error with the database. Please try again later.","message":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

because he is trying to create the same user instead of login again with discord.

[FEATURE]

Is your feature request related to a problem? Please describe.
Easier way to fetch images

Describe the solution you'd like
Currently, an image src tag for users and guilds looks something like this: "https://cdn.discordapp.com/avatars/" . Auth()->user()->id . "/" . Auth()->user()->avatar . ".png" }}"

I feel having a trait for guild icons and user avatars would be beneficial so that an src would be: Auth()->user()->getAvatar()

With some parameters for size, image type, and color for the default discord logo if the user has no profile picture

Additional context
If you feel like this would be a good feature, I'll work on a PR 👍

[FEATURE] More Config Options

Is your feature request related to a problem? Please describe.
Hey my FR is not related to a problem.

I have three things:

  1. Possibility to publish your things from vencdor to the "app" area to edit them. (Maybe its already possible and i am stupid to read the docs).
  2. Option to set the "prompt" setting to the .env. Im my case i want to see this message from Discord.
  3. Some Entrypoint to enter own Code after the successfull and unsuccessfull login. In my case, i want to check if the user is on a specific guild.

For more Information just ask.

Thanks for your work JakyeRU!

[BUG] Not found Bug with multiple guilds

Describe the bug
I have found out that in the DiscordController.php a simple but fatal error is with multipe guilds. This only occurs when a discord user is member only server (of 2 in this case)

In the Controller we have on line 88 a foreach loop, wich cause the problem.

But step by step.

In my case i have set in the config/larascord.php by the key "guilds" two Discord-Servers, like the following:

'guilds' => [
        123456789, // Name: A
        987654321, // Name: B
    ],

and at the

'guild_roles' => [
        // Server B
         '987654321' => [
             'XXX', // Role C
         ],
        // Server A
        '123456789' => [
            'XX', // Role A
            'X', // Role B
        ],
    ],

In my case i have created a new discord user wich is only member of Server B. If i now want to login, i get the error message: Couldn't get the roles you have. And further: HTTP request returned status code 404:\n{"message": "Unknown Guild", "code": 10004}\n

Okay, but what is now that problem there? After looking into your DiscordController a finaly found the bug: Its the foreach loop. The loop goes over the guild_roles, and my discord user is only part of one server. But the loop does not check this. My User is only on Server B as i say. So when the loop comes to Server A in the guild_roles key, then it throws the Exception because my user is not in the Server A.

So the solution/fix is, that this foreach loop must check however the user is on that server.

[BUG] Getting Users Mail Address

Describe the bug
In my .env i have the following scope:
LARASCORD_SCOPE=identify&guilds&guilds.members.read
I do not want the mail addresses of my users, but i get them how ever...

The Scope documentary: https://discord.com/developers/docs/topics/oauth2

identify | allows /users/@me without email

I do not have a clue, where this comes from. Even in the discord promt for the auth is nothing with the mail address wich will be shared.

Please ensure some Method or config option, to remove this behaviour.

At this situation i must setup a database trigger. This trigger sets after update the email colum to NULL

[FEATURE] Rename 'roles' database column to 'discord_roles'

Is your feature request related to a problem? Please describe.
I'm currently using Larascord, while also attempting to use the Laravel permission package by Spatie. I've recently run into errors using the permissions package. While debugging the issue, I found the issue.
image

The user model may not have a 'roles' attribute for the Permissions package to work. Larascord adds a 'roles' attribute, thus causing this issue.

Describe the solution you'd like
It'd be awesome if you could change the 'roles' column to 'discord_roles'. This does not have a negative effect on the other users of the package, while allowing users to use the very popular Laravel permission package by Spatie.

"HTTP request returned status code 429"

Hello there,

I have been using Larascord for a few days now and have changed up the guild_only function to suit my needs. Basically i am using the pre-made function getUserGuilds to store the users guilds along with their data each time they authenticate.

The only problem is that the server is hitting Discord's rate limit after very few attempts which is obviously a huge issue.

Just wanted to check if there were any quick solutions to this problem!

[FEATURE] Allow Login per Guild Role

Is your feature request related to a problem? Please describe.
I am currently building a Bugtracker for our Gaming community.
we only wan't people with a certain role to be able to login to the Site

Describe the solution you'd like
a way to add a Key-Value pair for guild-role permissions

[BUG] The MAC is invalid

{"larascord_message":{"message":"There was an error with the database. Please try again later.","redirect":"\/"},"message":"The MAC is invalid.","code":0}

Trying to diagnose why some auth features with larascord would cause me to logout, so I generated a new app_key and now I'm getting that.

[BUG] callback 404

url: http://localhost/discord/callback?code=ZmiDMbrJpgU00Fx4JaiJLVRfB2q1B4

Not Found
The requested URL was not found on this server.

web.php routes:

Route::get('/refresh', function () {
    $view = view('base');
    $query = request()->query('q');
    if ($query === 'uptime') {
        $view = view('function.uptime');
    } elseif ($query === 'counter') {
        $view = view('function.counter');
    } elseif ($query === 'chat') {
        $view = view('function.chat');
    }
    return $view;
});

//Route::get('/logout', [AuthenticatedSessionController::class, 'destroy'])->name('logout');
Route::get('/dashboard', function () {
    return view('dashboard');
})->middleware(['auth'])->name('dashboard');

Route::middleware('auth')->group(function () {
    Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
});

I don't think it installed the callback route?

[FEATURE] Multiple (sub)domain support

Is your feature request related to a problem? Please describe.
I'm not able to use Larascord for authentication over multiple subdomains (on the same Laravel installation), I'm ending in a endless redirect loop. Authentication worked before I changed the routing setup to allow a main domain and subdomain.

Describe the solution you'd like
I would like to be able to share my Discord login over multiple subdomains and the main domain off my application.

Describe alternatives you've considered
I've used a few StackOverflow pages since I've had some difficulties with sharing authentication over multiple subdomains in the same laravel installation. For example:
https://stackoverflow.com/a/56500425

Additional context

[BUG] The authorization code is invalid invalid_client

Describe the bug
Unable to log into the site via Discord, callback presents error:
https://wdwr.online/larascord/callback?code=redacted

{"larascord_message":{"message":"The authorization code is invalid.","redirect":"\/"},"message":"HTTP request returned status code 401:\n{\"error\": \"invalid_client\"}\n","code":401}

Larascord config:
LARASCORD_CLIENT_ID="1133727524917084211"
LARASCORD_CLIENT_SECRET="**************"
LARASCORD_GRANT_TYPE="authorization_code"
LARASCORD_PREFIX="larascord"
LARASCORD_SCOPE="identify&email"

To Reproduce
Steps to reproduce the behavior:

  1. install and configure larascord
  2. redirect not-logged in user to login route
  3. login with discord
  4. See error

Expected behavior
Expected to log in and redirect to /

Screenshots/Videos
image

Desktop (please complete the following information):

  • OS: Mac OS Montery 12.6.3
  • Browser + Version: Firefox 115.0.2 (64 BIT)
  • Laravel Version: Laravel Framework 10.16.1
  • PHP Version: PHP 8.2.8 (cli) (built: Jul 4 2023 14:52:54) (NTS gcc x86_64)

Additional context

[BUG] Re-Login after registration

Bug
If you try to log in again after registering, you get a message that the user is already registered instead of logging back into the account.

Reproduce

  1. Go to Index
  2. Click on Login
  3. Authorize your discord
  4. See Error below

Error
{"discord_message":"There was an error with the database. Please try again later.","message":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'USERNAME' for key 'users.username' (SQL: insert into users (username, mail) values (USERNAME,[email protected]))","code":"XXXXX"}

Additional
This error only comes if I already authorized me with my discord and exists in my database.

Versions

  • Laravel 9.19
  • PHP 8.1.10

Dear JakyeRU, I only can explain the way I did here, I don't know how I can tell you more about the Bug/Issue because I do it all just like that, I you need more information, you need to tell me more what you need.

[BUG] Version Missmatch

Describe the bug
Version missmatch. Once installed with PHP7.4 there are no longer errors. But i click on "login", then there is a error cause of php8 i guess.

Screenshots/Videos
Screenshot

Additional context
If PHP8 is required, then there should be a notice in the README or so. That this doesnt happend anymore.

Thanks.

[BUG] cURL error 60: SSL certificate problem: unable to get local issuer certificate

Describe the bug
I installed the plugin as shown and also followed the necessary configuration steps, but after logging into discord I get the message "Something went wrong! The authorization code is invalid." and I'm not logged in. I don't know what i did wrong.

To Reproduce
Steps to reproduce the behavior:

  • createt fresh laravel project with composer
  • installed php 8.1.1 and made shure, that laravel is using this version
  • followed the installation instructions as listed

Expected behavior
The authorization process should proceed without errors.

Screenshots/Videos
Screenshot_1423

Desktop (please complete the following information):

  • Windows 11 Version 21H2 (Build 22000.434)
  • Google Chrome Version 97.0.4692.71 (Offizieller Build) (64-Bit)
  • Laravel Framework 8.80.0
  • PHP 8.1.1 (cli) (built: Dec 15 2021 10:31:43) (ZTS Visual C++ 2019 x64)

Additional context
I have no idea if or what I did wrong. I followed the instructions, but I didn't get any further error messages as shown in the screenshot. I would like to use this plugin because it makes things a lot easier and I absolutely need a web-based dashboard for my discord bot.

[BUG] User will be created in database despite it the user has not the certain roles

I have found the following bug:

If you have enabled that a user must be member of a certain guild with certain roles then this bug occurs:

If the user is member of the guild and has not the certain roles as defined, the user will despite it created in the user table and that is strange.

Please fix this behaviour, its really strange for me, that users occurs in my user table without the certain roles.

[FEATURE] make it so it only does what it is supposed to and not deletes everything you have done

I am a bit mad because this library literally removed everything I have been working on for the past 4 days, I was able to recover some of it but this library still messed up a lot,

Make it so it doesn't delete everything and installs a whole new laravel project, it should be just something you add and use the feature you want to and change the whole project configuration, just do so people can configure what they want and not so they don't end up like me and lose all progress thinking they only downloading a simple library like laravel socialite

[FEATURE] After login redirect

Hey i have just installed a fresh version of Larascord.

After a login, i will get a redirect to /home, but i dont need this and i dont find any config option to change these.

In my routes/web.php i have the following work-a-round;

Route::get('/home', function () {
    return redirect('/');
});

So it would very nice to have these option to set a route.

[FEATURE] Templates

Is your feature request related to a problem? Please describe.
Fetch templates

Describe the solution you'd like
Template type, and fetch template method

Additional context
Not sure what path you're looking for Larascord to take, but in the application we're developing we have added template, and bot advertising. Templates do not require OAuth, so not sure if you'd like this feature added.

However if you're looking to expand Larascord to handle more aspects of Discord aside from OAuth, I'd be happy to implement server template fetching. And later on bot fetching.

[FEATURE] Soft deleting users

Is your feature request related to a problem? Please describe.
In my project which uses Larascord, I'd like to soft delete users, to have a way to block/remove users from the application. Whenever I soft delete a user and the user logs in again, it doesn't look at existing eccounts which are soft deleted. Instead, it tries to create a new user, resulting in an integrity constraint violation.

Describe the solution you'd like
It would be awesome if Larascord would check whether or not there's a user which has been soft deleted when creating a new user. Additionally, Larascord should provide an error message to the user when the account has been soft deleted, possibly making use of the success message 'user_deleted'.

[FEATURE]

Is your feature request related to a problem? Please describe.
Fetching guild member counts is a separate URL.

Describe the solution you'd like
Thinking maybe a separate method, or adding member counts to the current fetch guilds method in DiscordService.

Additional context
I added member counts to the current fetch guilds method to fit my personal needs in my project, I would like to contribute this method, or create a second method that includes the guild member counts to fit other's needs that may want this feature.

[BUG] The Authorization Code is Invalid

Describe the bug
After install, I ran php artisan larascord:install and it installed correctly, I ran the migration, and now when I hit my /login route it works, then it says, "The authorization code is invalid." 401 code

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://growsolar.us/main
  2. Click on Login
  3. Authenticate
  4. See error

Expected behavior
Login

Screenshots/Videos
If applicable, add screenshots/videos to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. Windows 10] Windows 11
  • Browser + Version [e.g. Version 1.34.80 Chromium: 97.0.4692.71 (Official Build) (64-bit)] -- Firefox latest
  • Laravel Version [e.g. v8.6.10] -- 9.XX
  • PHP Version [e.g 8.1.1] 8.1.X

Additional context
Add any other context about the problem here.

[FEATURE] Doubt - Redirection to pages

Is it possible to redirect the different errors to different pages?
I need to redirect users who are not in the guild to a page that will have the discord join link.

    'error_messages' => [
        'missing_code' => 'The authorization code is missing.',
        'invalid_code' => 'The authorization code is invalid.',
        'authorization_failed' => 'The authorization failed.',
        'missing_email' => 'Couldn\'t get your e-mail address.',
        'invalid_user' => 'The user ID doesn\'t match the logged-in user.',
        'database_error' => 'There was an error with the database. Please try again later.',
        'missing_guilds_scope' => 'The "guilds" scope is required.',
        'authorization_failed_guilds' => 'Couldn\'t get the servers you\'re in.',
        'not_member_guild_only' => 'You are not allowed to login.',
    ],

[FEATURE]

Will this support Laravel Jetstream?

[BUG] The authorization code is invalid on mobile

Describe the bug
When trying to log-in on mobile I get this error, but on my computer it works fine

To Reproduce
Steps to reproduce the behavior:

  1. Go to my website on my phone
  2. Login
  3. See error

Screenshots/Videos

{"larascord_message":"The authorization code is invalid.","message":"HTTP request returned status code 400:\n{\"error\": \"invalid_grant\", \"error_description\": \"Invalid \\\"code\\\" in request.\"}\n","code":400}

Desktop (please complete the following information):

  • OS: Android 11 MIUI 12.5.1
  • Browser: OperaGX, on desktop works fine.
  • Laravel Version: 9.34.0
  • PHP Version: 8.1.11

Additional context
I have disabled adblock and all blocking settings from the app and still the same

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.