mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Added basic login
This commit is contained in:
1 parent
bde4e861c2
commit
4224875fb0
14 files changed
+524
-5
No files matched your search
@@ -0,0 +1,36 @@
|
||||
using Artemis.WebClient.Workshop.Entities;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.WebClient.Workshop.Repositories;
|
||||
|
||||
internal class AuthenticationRepository : IAuthenticationRepository
|
||||
{
|
||||
private readonly LiteRepository _repository;
|
||||
|
||||
public AuthenticationRepository(LiteRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_repository.Database.GetCollection<RefreshTokenEntity>().EnsureIndex(s => s.RefreshToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetRefreshToken(string? refreshToken)
|
||||
{
|
||||
_repository.Database.GetCollection<RefreshTokenEntity>().DeleteAll();
|
||||
|
||||
if (refreshToken != null)
|
||||
_repository.Insert(new RefreshTokenEntity {RefreshToken = refreshToken});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string? GetRefreshToken()
|
||||
{
|
||||
return _repository.Query<RefreshTokenEntity>().FirstOrDefault()?.RefreshToken;
|
||||
}
|
||||
}
|
||||
|
||||
internal interface IAuthenticationRepository
|
||||
{
|
||||
void SetRefreshToken(string? refreshToken);
|
||||
string? GetRefreshToken();
|
||||
}
|
||||
Reference in new issue
Block a user