Skip to content

Commit ee1601f

Browse files
Merge pull request #86 from nullinside-development-group/fix/banned
fix: skipping banned users
2 parents d7a7e53 + 7eeec64 commit ee1601f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/Nullinside.Api.TwitchBot/Controllers/BotController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public BotController(INullinsideContext dbContext, IConfiguration configuration)
6262
return Unauthorized();
6363
}
6464

65-
User? user = _dbContext.Users.FirstOrDefault(u => u.Id == int.Parse(userId.Value));
65+
User? user = _dbContext.Users.FirstOrDefault(u => u.Id == int.Parse(userId.Value) && !u.IsBanned);
6666
if (null == user || null == user.TwitchToken || null == user.TwitchRefreshToken ||
6767
null == user.TwitchTokenExpiration || null == user.TwitchId) {
6868
return Unauthorized();
@@ -90,7 +90,7 @@ public async Task<IActionResult> ModBotAccount([FromServices] ITwitchApiProxy ap
9090
return Unauthorized();
9191
}
9292

93-
User? user = _dbContext.Users.FirstOrDefault(u => u.Id == int.Parse(userId.Value));
93+
User? user = _dbContext.Users.FirstOrDefault(u => u.Id == int.Parse(userId.Value) && !u.IsBanned);
9494
if (null == user || null == user.TwitchToken || null == user.TwitchRefreshToken ||
9595
null == user.TwitchTokenExpiration || null == user.TwitchId) {
9696
return Unauthorized();
@@ -114,7 +114,7 @@ public async Task<IActionResult> GetConfig(CancellationToken token) {
114114
return Unauthorized();
115115
}
116116

117-
User? user = await _dbContext.Users.FirstOrDefaultAsync(u => u.Id == int.Parse(userId.Value), token);
117+
User? user = await _dbContext.Users.FirstOrDefaultAsync(u => u.Id == int.Parse(userId.Value) && !u.IsBanned, token);
118118
if (null == user) {
119119
return Unauthorized();
120120
}

src/Nullinside.Api.TwitchBot/Model/NullinsideContextExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static void Configure(this ITwitchApiProxy api, User user) {
121121
/// <returns>The number of state entries written to the database.</returns>
122122
private static async Task<int> UpdateOAuthInDatabase(this INullinsideContext db, int userId,
123123
TwitchAccessToken oAuth, CancellationToken stoppingToken = new()) {
124-
User? row = await db.Users.FirstOrDefaultAsync(u => u.Id == userId, stoppingToken);
124+
User? row = await db.Users.FirstOrDefaultAsync(u => u.Id == userId && !u.IsBanned, stoppingToken);
125125
if (null == row) {
126126
return -1;
127127
}

src/nullinside-api

0 commit comments

Comments
 (0)