jakyeru / larascord Goto Github PK
View Code? Open in Web Editor NEWLarascord is a package that allows you to authenticate users in your Laravel application using Discord.
Home Page: https://larascord.jakye.me
License: MIT License
Larascord is a package that allows you to authenticate users in your Laravel application using Discord.
Home Page: https://larascord.jakye.me
License: MIT License
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 }
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.
{"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.
Hello, is it possible to use MongoDB instead of MySQL? What changes would I need to make?
Have a nice day
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
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:
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):
Additional context
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
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
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.
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.
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:
Expected behavior
The authorization process should proceed without errors.
Desktop (please complete the following information):
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.
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'.
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
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.
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.
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.
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.
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 👍
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.
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:
Expected behavior
Login
Screenshots/Videos
If applicable, add screenshots/videos to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
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.
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
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!
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
Will this support Laravel Jetstream?
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:
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):
Additional context
I have disabled adblock and all blocking settings from the app and still the same
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?
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
curl -s https://laravel.build/main-app| bash
then cd main-app
composer require jakyeru/larascord
& php artisan larascord:install
Desktop (please complete the following information):
Additional context
I did change at the end
APP_URL=https://exi.srpeter.com/
Is your feature request related to a problem? Please describe.
Hey my FR is not related to a problem.
I have three things:
For more Information just ask.
Thanks for your work JakyeRU!
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.
Is there any plans to add support of the 11 version ?
Describe the bug
The GET method is not supported for route logout. Supported methods: POST.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
You should logout from the dashbaord.
Desktop (please complete the following information):
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:
Expected behavior
Expected to log in and redirect to /
Desktop (please complete the following information):
Additional context
Hello Jakye,
I tried using Larascord, but I got the error in the title. Did everything. Went all default on the installation options.
Screenshot: click here
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.',
],
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.