mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Implements authentication system
This commit is contained in:
1 parent
38829d64ff
commit
a6dcf65d1c
103 files changed
+2983
-454
No files matched your search
@@ -64,4 +64,19 @@ internal sealed class UserRepository : IUserRepository
|
||||
{
|
||||
return await _luminaDbContext.Users.FirstOrDefaultAsync(user => user.Username == username, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an user.
|
||||
/// </summary>
|
||||
/// <param name="data">Ther user to update.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="ErrorOr{TValue}"/> representing either a successfull operation, or an error.</returns>
|
||||
public async Task<ErrorOr<Updated>> UpdateAsync(UserEntity data, CancellationToken cancellationToken)
|
||||
{
|
||||
UserEntity? foundUser = await _luminaDbContext.Users.FirstOrDefaultAsync(user => user.Username == data.Username, cancellationToken).ConfigureAwait(false);
|
||||
if (foundUser is null)
|
||||
return Errors.Users.UserDoesNotExist;
|
||||
_luminaDbContext.Entry(foundUser).CurrentValues.SetValues(data);
|
||||
return Result.Updated;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user