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"
[[package]]
name = "medal"
version = "1.7.0"
version = "1.7.1"
dependencies = [
"bcrypt",
"csv",
......
[package]
version = "1.7.0"
version = "1.7.1"
name = "medal"
authors = ["Robert Czechowski <czechowski@bwinf.de>", "Daniel Brüning <bruening@bwinf.de>"]
......
......@@ -58,6 +58,7 @@ pub enum MedalError {
PasswordHashingError,
UnmatchedPasswords,
NotFound,
AccountIncomplete,
OauthError(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)
-> (String, json_val::Map<String, json_val::Value>) {
-> MedalValueResult {
let mut data = json_val::Map::new();
if let Some(token) = session_token {
if let Some(session) = conn.get_session(&token) {
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);
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)
......@@ -842,11 +847,11 @@ pub fn show_group<T: MedalConnection>(conn: &T, group_id: i32, session_token: &s
let v: Vec<MemberInfo> =
group.members
.iter()
.map(|m| MemberInfo { id: m.id,
firstname: m.firstname.clone().unwrap_or_else(|| "".to_string()),
lastname: m.lastname.clone().unwrap_or_else(|| "".to_string()),
grade: grade_to_string(m.grade),
logincode: m.logincode.clone().unwrap_or_else(|| "".to_string()) })
.filter_map(|m| Some(MemberInfo { id: m.id,
firstname: m.firstname.clone()?,
lastname: m.lastname.clone()?,
grade: grade_to_string(m.grade),
logincode: m.logincode.clone()? }))
.collect();
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 {
core::MedalError::NotFound => IronError { error: Box::new(SessionError { message:
"Not found".to_string() }),
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) => {
IronError { error: Box::new(SessionError { message: format!("Access denied (Error {})", errstr) }),
response: Response::with(status::Unauthorized) }
......@@ -322,7 +327,7 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response>
// hier ggf. Daten aus dem Request holen
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));
......
......@@ -2,12 +2,7 @@
{{#if logged_in}}
Eingeloggt als <em>{{ username }}</em>
{{#if firstname}}
({{firstname}}
{{/if}}
{{#if lastname}}
{{lastname}})
{{/if}}
{{#if firstname}}{{firstname}}{{/if}} {{#if lastname}}{{lastname}}{{/if}}
{{#if teacher}}
[Lehrer]
......
......@@ -40,9 +40,7 @@
<div class="columns" style="margin-bottom: 0px;">
<div class="column is-8">
Eingeloggt als <em>{{ username }}</em>
{{#if firstname}}{{#if lastname}}
{{firstname}} {{lastname}}
{{/if}}{{/if}}
{{#if firstname}}{{firstname}}{{/if}} {{#if lastname}}{{lastname}}{{/if}}
{{#if admin}}
[ADMIN]
{{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