mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-18 15:42:26 +00:00
Add get user by username api endpoint
This commit is contained in:
parent
5bc875bc04
commit
355ec45b20
1 changed files with 11 additions and 0 deletions
|
@ -39,6 +39,17 @@ public class UserEndpoints : ApiEndpointController
|
|||
return this.Ok(user);
|
||||
}
|
||||
|
||||
[HttpGet("username/{username}")]
|
||||
[ProducesResponseType(typeof(User), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> GetUser(string username)
|
||||
{
|
||||
User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username == username);
|
||||
if (user == null) return this.NotFound();
|
||||
|
||||
return this.Ok(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a user and their information from the database.
|
||||
/// </summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue