Commit 9c810a54 authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Merge branch 'v1.7' into deploy

parents e8b954bc 854dec84
Pipeline #968 passed with stages
in 17 minutes and 52 seconds
...@@ -1064,7 +1064,7 @@ checksum = "79c56d6a0b07f9e19282511c83fc5b086364cbae4ba8c7d5f190c3d9b0425a48" ...@@ -1064,7 +1064,7 @@ checksum = "79c56d6a0b07f9e19282511c83fc5b086364cbae4ba8c7d5f190c3d9b0425a48"
[[package]] [[package]]
name = "medal" name = "medal"
version = "1.7.0" version = "1.7.1"
dependencies = [ dependencies = [
"bcrypt", "bcrypt",
"csv", "csv",
......
[package] [package]
version = "1.7.0" version = "1.7.1"
name = "medal" name = "medal"
authors = ["Robert Czechowski <czechowski@bwinf.de>", "Daniel Brüning <bruening@bwinf.de>"] authors = ["Robert Czechowski <czechowski@bwinf.de>", "Daniel Brüning <bruening@bwinf.de>"]
......
...@@ -58,6 +58,7 @@ pub enum MedalError { ...@@ -58,6 +58,7 @@ pub enum MedalError {
PasswordHashingError, PasswordHashingError,
UnmatchedPasswords, UnmatchedPasswords,
NotFound, NotFound,
AccountIncomplete,
OauthError(String), OauthError(String),
} }
...@@ -121,19 +122,23 @@ fn grade_to_string(grade: i32) -> String { ...@@ -121,19 +122,23 @@ fn grade_to_string(grade: i32) -> String {
} }
pub fn index<T: MedalConnection>(conn: &T, session_token: Option<String>, login_info: LoginInfo) pub fn index<T: MedalConnection>(conn: &T, session_token: Option<String>, login_info: LoginInfo)
-> (String, json_val::Map<String, json_val::Value>) { -> MedalValueResult {
let mut data = json_val::Map::new(); let mut data = json_val::Map::new();
if let Some(token) = session_token { if let Some(token) = session_token {
if let Some(session) = conn.get_session(&token) { if let Some(session) = conn.get_session(&token) {
fill_user_data(&session, &mut data); fill_user_data(&session, &mut data);
if session.logincode.is_some() && session.firstname.is_none() {
return Err(MedalError::AccountIncomplete);
}
} }
} }
fill_oauth_data(login_info, &mut data); fill_oauth_data(login_info, &mut data);
data.insert("parent".to_string(), to_json(&"base")); data.insert("parent".to_string(), to_json(&"base"));
("index".to_owned(), data) Ok(("index".to_owned(), data))
} }
pub fn show_login<T: MedalConnection>(conn: &T, session_token: Option<String>, login_info: LoginInfo) pub fn show_login<T: MedalConnection>(conn: &T, session_token: Option<String>, login_info: LoginInfo)
...@@ -842,11 +847,11 @@ pub fn show_group<T: MedalConnection>(conn: &T, group_id: i32, session_token: &s ...@@ -842,11 +847,11 @@ pub fn show_group<T: MedalConnection>(conn: &T, group_id: i32, session_token: &s
let v: Vec<MemberInfo> = let v: Vec<MemberInfo> =
group.members group.members
.iter() .iter()
.map(|m| MemberInfo { id: m.id, .filter_map(|m| Some(MemberInfo { id: m.id,
firstname: m.firstname.clone().unwrap_or_else(|| "".to_string()), firstname: m.firstname.clone()?,
lastname: m.lastname.clone().unwrap_or_else(|| "".to_string()), lastname: m.lastname.clone()?,
grade: grade_to_string(m.grade), grade: grade_to_string(m.grade),
logincode: m.logincode.clone().unwrap_or_else(|| "".to_string()) }) logincode: m.logincode.clone()? }))
.collect(); .collect();
data.insert("group".to_string(), to_json(&gi)); data.insert("group".to_string(), to_json(&gi));
......
This diff is collapsed.
This diff is collapsed.
...@@ -293,6 +293,11 @@ impl<'c, 'a, 'b> From<AugMedalError<'c, 'a, 'b>> for IronError { ...@@ -293,6 +293,11 @@ impl<'c, 'a, 'b> From<AugMedalError<'c, 'a, 'b>> for IronError {
core::MedalError::NotFound => IronError { error: Box::new(SessionError { message: core::MedalError::NotFound => IronError { error: Box::new(SessionError { message:
"Not found".to_string() }), "Not found".to_string() }),
response: Response::with(status::NotFound) }, response: Response::with(status::NotFound) },
core::MedalError::AccountIncomplete => IronError { error: Box::new(SessionError { message:
"Account incomplete".to_string() }),
response: Response::with((status::Found,
Redirect(iron::Url::parse(&format!("{}?status=firstlogin",
&url_for!(req, "profile"))).unwrap()))) },
core::MedalError::OauthError(errstr) => { core::MedalError::OauthError(errstr) => {
IronError { error: Box::new(SessionError { message: format!("Access denied (Error {})", errstr) }), IronError { error: Box::new(SessionError { message: format!("Access denied (Error {})", errstr) }),
response: Response::with(status::Unauthorized) } response: Response::with(status::Unauthorized) }
...@@ -322,7 +327,7 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response> ...@@ -322,7 +327,7 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response>
// hier ggf. Daten aus dem Request holen // hier ggf. Daten aus dem Request holen
let config = req.get::<Read<SharedConfiguration>>().unwrap(); let config = req.get::<Read<SharedConfiguration>>().unwrap();
let (template, mut data) = with_conn![core::index, C, req, session_token, login_info(&config)]; let (template, mut data) = with_conn![core::index, C, req, session_token, login_info(&config)].aug(req)?;
data.insert("config".to_string(), to_json(&config.template_params)); data.insert("config".to_string(), to_json(&config.template_params));
......
...@@ -2,12 +2,7 @@ ...@@ -2,12 +2,7 @@
{{#if logged_in}} {{#if logged_in}}
Eingeloggt als <em>{{ username }}</em> Eingeloggt als <em>{{ username }}</em>
{{#if firstname}} {{#if firstname}}{{firstname}}{{/if}} {{#if lastname}}{{lastname}}{{/if}}
({{firstname}}
{{/if}}
{{#if lastname}}
{{lastname}})
{{/if}}
{{#if teacher}} {{#if teacher}}
[Lehrer] [Lehrer]
......
...@@ -40,9 +40,7 @@ ...@@ -40,9 +40,7 @@
<div class="columns" style="margin-bottom: 0px;"> <div class="columns" style="margin-bottom: 0px;">
<div class="column is-8"> <div class="column is-8">
Eingeloggt als <em>{{ username }}</em> Eingeloggt als <em>{{ username }}</em>
{{#if firstname}}{{#if lastname}} {{#if firstname}}{{firstname}}{{/if}} {{#if lastname}}{{lastname}}{{/if}}
{{firstname}} {{lastname}}
{{/if}}{{/if}}
{{#if admin}} {{#if admin}}
[ADMIN] [ADMIN]
{{else}} {{else}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment