Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync() {
.AsNoTracking()
.FirstOrDefaultAsync(u => !string.IsNullOrWhiteSpace(u.Token) &&
u.Token == token &&
!u.IsBanned).ConfigureAwait(false);
!u.IsBanned)
.ConfigureAwait(false);

if (null == dbUser) {
return AuthenticateResult.Fail("Invalid token");
Expand Down
8 changes: 3 additions & 5 deletions src/Nullinside.Api.Common/Auth/AuthUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ namespace Nullinside.Api.Common.Auth;
/// </summary>
public static class AuthUtils {
/// <summary>
/// Generates a new unique bearer token.
/// Generates a new unique token.
/// </summary>
/// <returns>A bearer token.</returns>
public static string GenerateBearerToken() {
// This method is trash but it doesn't matter. We should be doing real OAuth tokens with expirations and
// renewals. Right now nothing that exists on the site requires this level of sophistication.
/// <returns>A token.</returns>
public static string GenerateToken() {
string allowed = "ABCDEFGHIJKLMONOPQRSTUVWXYZabcdefghijklmonopqrstuvwxyz0123456789";
int strlen = 255; // Or whatever
char[] randomChars = new char[strlen];
Expand Down
12 changes: 12 additions & 0 deletions src/Nullinside.Api.Model/Ddl/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ public class User : ITableModel {
/// The user's auth token for interacting with the site's API.
/// </summary>
public string? Token { get; set; }

/// <summary>
/// The user's auth token for interacting with the site's API.
/// </summary>
public string? RefreshToken { get; set; }

/// <summary>
/// The user's auth token for interacting with the site's API.
/// </summary>
public DateTime? TokenExpires { get; set; }

/// <summary>
/// The id of the user on twitch.
Expand Down Expand Up @@ -95,6 +105,8 @@ public void OnModelCreating(ModelBuilder modelBuilder) {
.HasMaxLength(255);
entity.Property(e => e.Token)
.HasMaxLength(255);
entity.Property(e => e.RefreshToken)
.HasMaxLength(255);
entity.Property(e => e.UpdatedOn)
.IsRowVersion();
// TODO: Add the other strings in this file with lengths
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading