public async Task <string> CreateAsync(string username) { var refreshToken = new RefreshTokenDocument { Id = Guid.NewGuid(), Username = username, Token = Rng.Generate(30, true), CreatedAt = DateTime.UtcNow }; await _refreshTokensRepository.AddAsync(refreshToken); return(refreshToken.Token); }
public static RefreshToken AsEntity(this RefreshTokenDocument document) => new RefreshToken(document.Id, document.UserId, document.Token, document.CreatedAt, document.RevokedAt);
public async Task UpdateAsync(RefreshToken refreshToken) { var document = new RefreshTokenDocument(refreshToken); await _collection.ReplaceOneAsync(x => x.UserId == document.UserId, document); }