Skip to content

Commit 67ef4c4

Browse files
committed
Throw on invalid token data instead
1 parent 61463d0 commit 67ef4c4

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

Refresh.GameServer/Authentication/GameAuthenticationProvider.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,21 @@ public GameAuthenticationProvider(GameServerConfig? config, Logger logger)
7676
if ((this._config?.MaintenanceMode ?? false) && user.Role != GameUserRole.Admin)
7777
return null;
7878

79-
// Additional validation of the token gotten from DB
79+
// Additional validation of the token gotten from DB. Exceptions will be caught, logged and InternalServerError will be returned automatically.
8080
if (token.TokenData != tokenData)
8181
{
8282
#if DEBUG
8383
if(Debugger.IsAttached) Debugger.Break();
8484
#endif
85-
this._logger.LogError(BunkumCategory.Authentication, $"Token from DB does not match token received from client! Rejecting...");
86-
return null;
85+
throw new InvalidDataException($"{typeof(GameAuthenticationProvider)} - Token from DB does not match token received from client!");
8786
}
8887

8988
if (token.User.UserId != token.UserId)
9089
{
9190
#if DEBUG
9291
if(Debugger.IsAttached) Debugger.Break();
9392
#endif
94-
this._logger.LogError(BunkumCategory.Authentication, $"GameUser included with token is not the token owner! Rejecting...");
95-
return null;
93+
throw new InvalidDataException($"{typeof(GameAuthenticationProvider)} - GameUser included with token is not the token owner!");
9694
}
9795

9896
return token;

0 commit comments

Comments
 (0)