Auth endpoints

This commit is contained in:
AleksDw
2025-05-18 17:43:47 +02:00
parent 1eb104945a
commit bebf47a2ba
6 changed files with 174 additions and 18 deletions

View File

@@ -66,4 +66,25 @@ public class GeneralUseHelpers
}
return null;
}
public async Task<Token> CreateNewToken(int userId)
{
var token = new Token
{
UserId = userId,
Value = "lah-" + Guid.NewGuid().ToString(),
ValidUntil = DateTime.UtcNow.AddDays(7)
};
_context.Tokens.Add(token);
await _context.SaveChangesAsync();
return token;
}
public async Task DeleteToken(Token token)
{
_context.Tokens.Remove(token);
await _context.SaveChangesAsync();
}
}