Add LogoutSenderAsync method to AuthService
A new asynchronous method `LogoutSenderAsync` was added to the `AuthService` class to handle sender user logout. The method sends a POST request to the `/api/auth/logout` endpoint and removes the authentication cookie. It accepts an optional `CancellationToken` parameter and returns a `bool` indicating the success of the operation. XML documentation comments were included to describe the method's functionality.
This commit is contained in:
@@ -78,4 +78,16 @@ public class AuthService(HttpClient http, IOptions<ApiOptions> apiOptions)
|
|||||||
_ => SenderLoginResult.Error
|
_ => SenderLoginResult.Error
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Logs out the sender user by removing the authentication cookie.
|
||||||
|
/// Calls POST /api/auth/logout.
|
||||||
|
/// </summary>
|
||||||
|
public async Task<bool> LogoutSenderAsync(CancellationToken cancel = default)
|
||||||
|
{
|
||||||
|
var response = await http.PostAsync(
|
||||||
|
$"{_api.BaseUrl}/api/auth/logout",
|
||||||
|
null, cancel);
|
||||||
|
return response.IsSuccessStatusCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user