Can get user information

This commit is contained in:
2023-05-31 15:52:49 +02:00
parent 652541cd59
commit c0f120bb53
7 changed files with 98 additions and 9 deletions

View File

@ -6,6 +6,7 @@ use std::fmt::{Debug, Display, Formatter};
pub mod auth_controller;
pub mod config_controller;
pub mod user_controller;
/// Custom error to ease controller writing
#[derive(Debug)]

View File

@ -0,0 +1,15 @@
//! # User controller
//!
//! The actions of the user on his account when he is authenticated.
use crate::controllers::HttpResult;
use crate::services::login_token_service::LoginToken;
use crate::services::users_service;
use actix_web::HttpResponse;
/// Get account information
pub async fn auth_info(token: LoginToken) -> HttpResult {
let user = users_service::get_by_id(token.user_id).await?;
Ok(HttpResponse::Ok().json(user))
}