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]
name = "flotte-user-management"
version = "0.2.0"
version = "0.3.0"
authors = ["trivernis <trivernis@protonmail.com>"]
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"
sha2 = "0.9.2"

@ -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))
}

@ -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)]

Loading…
Cancel
Save