mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-19 07:52:27 +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);
|
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>
|
/// <summary>
|
||||||
/// Gets a user and their information from the database.
|
/// Gets a user and their information from the database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue