Skip to content

Commit

Permalink
Remove token from cache before returning responses in RoleService
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Jul 28, 2024
1 parent 91b9a43 commit cd11eac
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Refresh.GameServer/Services/RoleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ internal RoleService(AuthenticationService authService, GameServerConfig config,

// if the user's role is lower than the minimum role for this endpoint, then return unauthorized
if (user.Role < minimumRole)
{
this._authService.RemoveTokenFromCache();
return Unauthorized;
}

RequireEmailVerifiedAttribute? emailAttrib = method.GetCustomAttribute<RequireEmailVerifiedAttribute>();
if (emailAttrib != null && !user.EmailAddressVerified)
{
this._authService.RemoveTokenFromCache();
return Unauthorized;
}

return null;
}
Expand All @@ -59,7 +65,11 @@ internal RoleService(AuthenticationService authService, GameServerConfig config,

// If user isn't an admin, then stop the request here, ignoring all
if (user.Role != GameUserRole.Admin)
{
this._authService.RemoveTokenFromCache();
return Forbidden;
}


return null;
}
Expand Down

0 comments on commit cd11eac

Please sign in to comment.