Add profile_handler function to handle user profile requests
This commit is contained in:
@@ -71,6 +71,13 @@ impl Hooks for App {
|
|||||||
```rust
|
```rust
|
||||||
use loco_keycloak_auth::Keycloak;
|
use loco_keycloak_auth::Keycloak;
|
||||||
|
|
||||||
|
pub async fn profile_handler(
|
||||||
|
State(_ctx): State<AppContext>,
|
||||||
|
Extension(token): Extension<KeycloakToken<String>>,
|
||||||
|
) -> Result<Response> {
|
||||||
|
format::json(token.subject)
|
||||||
|
}
|
||||||
|
|
||||||
fn routes(ctx: &AppContext) -> Routes {
|
fn routes(ctx: &AppContext) -> Routes {
|
||||||
let keycloak = Keycloak::from_context(ctx).expect("Failed to create Keycloak layer");
|
let keycloak = Keycloak::from_context(ctx).expect("Failed to create Keycloak layer");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user