From b1c027bf7a3dc4246239c653237830895382f583 Mon Sep 17 00:00:00 2001 From: trivernis Date: Tue, 15 Dec 2020 13:47:56 +0100 Subject: [PATCH] Change return type of user field on login to UserFullInformation Signed-off-by: trivernis --- Cargo.toml | 4 ++-- src/server/http_server.rs | 9 ++++++++- src/server/messages.rs | 6 ++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1445e0b..ba38095 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "flotte-user-management" -version = "0.2.0" +version = "0.3.0" authors = ["trivernis "] edition = "2018" license = "GPL-3.0" @@ -37,4 +37,4 @@ regex = "1.4.2" lazy_static = "1.4.0" schemars = "0.8.0" syntect = "4.4.0" -sha2 = "0.9.2" \ No newline at end of file +sha2 = "0.9.2" diff --git a/src/server/http_server.rs b/src/server/http_server.rs index f238d2e..dab2476 100644 --- a/src/server/http_server.rs +++ b/src/server/http_server.rs @@ -272,13 +272,20 @@ impl UserHttpServer { let user = database .users .get_user(get_user_id_from_token(&tokens.request_token).unwrap())?; + let roles = database.user_roles.by_user(user.id)?; Ok(Response::json(&LoginResponse { request_token: tokens.request_token.clone(), refresh_token: tokens.refresh_token.clone(), request_ttl: tokens.request_ttl, refresh_ttl: tokens.refresh_ttl, - user, + user: UserFullInformation { + id: user.id, + name: user.name, + email: user.email, + attributes: user.attributes, + roles, + }, }) .with_status_code(201)) } diff --git a/src/server/messages.rs b/src/server/messages.rs index 4a3ee44..7a48f19 100644 --- a/src/server/messages.rs +++ b/src/server/messages.rs @@ -10,7 +10,9 @@ use serde::export::Formatter; use serde::{Deserialize, Serialize}; use zeroize::Zeroize; -use crate::database::models::{CreatePermissionsEntry, Permission, UserInformation}; +use crate::database::models::{ + CreatePermissionsEntry, Permission, UserFullInformation, UserInformation, +}; use crate::utils::error::DBError; use serde_json::Value; @@ -97,7 +99,7 @@ pub struct LoginResponse { pub refresh_token: String, pub request_ttl: i32, pub refresh_ttl: i32, - pub user: UserInformation, + pub user: UserFullInformation, } #[derive(Deserialize, Zeroize, JsonSchema)]