gitfox_client/auth.rs
1//! Authentication endpoints.
2
3use crate::client::GitFoxClient;
4use crate::error::Result;
5use crate::models::User;
6
7pub struct AuthApi<'a> {
8 client: &'a GitFoxClient,
9}
10
11impl<'a> AuthApi<'a> {
12 pub(crate) fn new(client: &'a GitFoxClient) -> Self {
13 Self { client }
14 }
15
16 /// `GET /api/v1/user` — also doubles as the token validity check used by
17 /// `gf auth login` and `gf auth status`.
18 pub async fn current_user(&self) -> Result<User> {
19 self.client.get_json("/api/v1/user").await
20 }
21}