Merge pull request #21 from fLotte-meets-HWR-DB/develop

Change return type of user field on login to UserFullInformation
main
Trivernis 4 years ago committed by GitHub
commit 912c15b874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,6 @@
[package] [package]
name = "flotte-user-management" name = "flotte-user-management"
version = "0.2.0" version = "0.3.0"
authors = ["trivernis <trivernis@protonmail.com>"] authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018" edition = "2018"
license = "GPL-3.0" license = "GPL-3.0"

@ -272,13 +272,20 @@ impl UserHttpServer {
let user = database let user = database
.users .users
.get_user(get_user_id_from_token(&tokens.request_token).unwrap())?; .get_user(get_user_id_from_token(&tokens.request_token).unwrap())?;
let roles = database.user_roles.by_user(user.id)?;
Ok(Response::json(&LoginResponse { Ok(Response::json(&LoginResponse {
request_token: tokens.request_token.clone(), request_token: tokens.request_token.clone(),
refresh_token: tokens.refresh_token.clone(), refresh_token: tokens.refresh_token.clone(),
request_ttl: tokens.request_ttl, request_ttl: tokens.request_ttl,
refresh_ttl: tokens.refresh_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)) .with_status_code(201))
} }

@ -10,7 +10,9 @@ use serde::export::Formatter;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use zeroize::Zeroize; use zeroize::Zeroize;
use crate::database::models::{CreatePermissionsEntry, Permission, UserInformation}; use crate::database::models::{
CreatePermissionsEntry, Permission, UserFullInformation, UserInformation,
};
use crate::utils::error::DBError; use crate::utils::error::DBError;
use serde_json::Value; use serde_json::Value;
@ -97,7 +99,7 @@ pub struct LoginResponse {
pub refresh_token: String, pub refresh_token: String,
pub request_ttl: i32, pub request_ttl: i32,
pub refresh_ttl: i32, pub refresh_ttl: i32,
pub user: UserInformation, pub user: UserFullInformation,
} }
#[derive(Deserialize, Zeroize, JsonSchema)] #[derive(Deserialize, Zeroize, JsonSchema)]

Loading…
Cancel
Save