Compare commits
2 commits
cb75412d19
...
65ba3a6435
Author | SHA1 | Date | |
---|---|---|---|
65ba3a6435 | |||
a57515c33e |
2 changed files with 10 additions and 3 deletions
|
@ -35,7 +35,7 @@ public class AuthController(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (user is null)
|
if (user is null)
|
||||||
return Forbid();
|
return this.BadRequest();
|
||||||
|
|
||||||
var session = await authService.CreateStrongSession(user.Id);
|
var session = await authService.CreateStrongSession(user.Id);
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,17 @@ internal class AuthService(AuthContext context, SessionStorage storage) : IAuthS
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return await context
|
var user = await context
|
||||||
.Users.Where(u => u.Username == username)
|
.Users.Where(u => u.Username == username)
|
||||||
.Select(u => new UserInfo(u.Id, u.Username, u.Roles.Select(r => r.Role).ToList()))
|
|
||||||
.SingleOrDefaultAsync(cancellationToken);
|
.SingleOrDefaultAsync(cancellationToken);
|
||||||
|
|
||||||
|
if (user is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (!user.HasPassword(password))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new UserInfo(user.Id, user.Username, user.Roles.Select(r => r.Role).ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<UserInfo?> GetUserWithId(Guid? userId, CancellationToken cancellationToken)
|
public Task<UserInfo?> GetUserWithId(Guid? userId, CancellationToken cancellationToken)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue