diff --git a/docs/pages/configuration.mdx b/docs/pages/configuration.mdx index 6b9c1c7..c14cf7d 100644 --- a/docs/pages/configuration.mdx +++ b/docs/pages/configuration.mdx @@ -160,9 +160,6 @@ return [ */ // WARNING: This feature makes one request to the Discord API for each guild you specify. (Because you need to fetch the roles for each guild) - // At the moment the database is not checked for roles when the user logs in. It will always fetch the roles from the Discord API. - // Currently, the roles are only updated in the database when the user logs in. The roles from the database can be used in a middleware. - // I'm working on a better way to do this, but for now, this will work. 'guild_roles' => [ // 'guild_id' => [ diff --git a/src/Http/Controllers/DiscordController.php b/src/Http/Controllers/DiscordController.php index cd3a187..34fd1c1 100644 --- a/src/Http/Controllers/DiscordController.php +++ b/src/Http/Controllers/DiscordController.php @@ -111,8 +111,6 @@ public function handle(StoreUserRequest $request): RedirectResponse | JsonRespon DB::rollBack(); return $this->throwError('missing_role'); } - - (new DiscordService())->updateUserRoles($user, $guildMember, $guildId); } } catch (\Exception $e) { DB::rollBack(); diff --git a/src/Services/DiscordService.php b/src/Services/DiscordService.php index ef1035d..8ec8bbf 100644 --- a/src/Services/DiscordService.php +++ b/src/Services/DiscordService.php @@ -228,18 +228,6 @@ public function hasRoleInGuild(GuildMember $guildMember, array $roles): bool return !empty(array_intersect($roles, $guildMember->roles)); } - /** - * Updates the user's roles in the database. - */ - public function updateUserRoles(User $user, GuildMember $guildMember, int $guildId): void - { - // Updating the user's roles in the database. - $updatedRoles = $user->roles; - $updatedRoles[$guildId] = $guildMember->roles; - $user->roles = $updatedRoles; - $user->save(); - } - /** * Revoke the user's access token. * diff --git a/src/config/config.php b/src/config/config.php index db3f677..2d154c0 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -136,9 +136,6 @@ */ // WARNING: This feature makes one request to the Discord API for each guild you specify. (Because you need to fetch the roles for each guild) - // At the moment the database is not checked for roles when the user logs in. It will always fetch the roles from the Discord API. - // Currently, the roles are only updated in the database when the user logs in. The roles from the database can be used in a middleware. - // I'm working on a better way to do this, but for now, this will work. 'guild_roles' => [ // 'guild_id' => [ diff --git a/src/database/migrations/2023_04_06_101123_add_roles_to_users_table.php b/src/database/migrations/2023_04_06_101123_add_roles_to_users_table.php deleted file mode 100644 index 0ed6c34..0000000 --- a/src/database/migrations/2023_04_06_101123_add_roles_to_users_table.php +++ /dev/null @@ -1,28 +0,0 @@ -json('roles')->nullable()->after('avatar'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('roles'); - }); - } -};