Commit 0b15defc authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Show OAuth login options on login page

parent 57007006
Pipeline #220 passed with stage
in 7 minutes and 51 seconds
......@@ -271,8 +271,7 @@ fn greet_personal<C>(req: &mut Request) -> IronResult<Response>
// Antwort erstellen und zurücksenden
core::index(&*conn, session_token, (self_url, oauth_providers))
};
// Daten verarbeiten
// Antwort erstellen und zurücksenden
let mut resp = Response::new();
resp.set_mut(Template::new(&template, data)).set_mut(status::Ok);
......@@ -380,18 +379,31 @@ fn contest_post<C>(req: &mut Request) -> IronResult<Response>
fn login<C>(req: &mut Request) -> IronResult<Response>
where C: MedalConnection + std::marker::Send + 'static {
// TODO: Use OAuth providers
let (self_url, _oauth_providers) = {
let (self_url, oauth_providers) = {
let mutex = req.get::<Write<SharedConfiguration>>().unwrap();
let config = mutex.lock().unwrap_or_else(|e| e.into_inner());
(config.self_url.clone(), config.oauth_providers.clone())
};
let mut data = json_val::Map::new();
let query_string = req.url.query().map(|s| s.to_string());
if let Some(query) = query_string {
data.insert("forward".to_string(), to_json(&query));
}
let mut oauth_links: Vec<(String, String, String)> = Vec::new();
if let Some(oauth_providers) = oauth_providers {
for oauth_provider in oauth_providers {
oauth_links.push((oauth_provider.provider_id.to_owned(),
oauth_provider.login_link_text.to_owned(),
oauth_provider.url.to_owned()));
}
}
data.insert("self_url".to_string(), to_json(&self_url));
// TODO: Generate list of links as in greet_personal
// data.insert("oauth_url".to_string(), to_json(&oauth_url));
data.insert("oauth_links".to_string(), to_json(&oauth_links));
let mut resp = Response::new();
resp.set_mut(Template::new("login", data)).set_mut(status::Ok);
......
......@@ -25,8 +25,8 @@
{{#if oauth_url}}
{{#if self_url}}
<p><a href="{{ oauth_url }}{{ self_url }}/oauth">PMS-Login</a>
{{/if}}
{{#each oauth_links}}
<a href="{{ this.2 }}{{ ../self_url }}/oauth/{{ this.0 }}">{{ this.1 }}</a>
{{/each}}
{{/if}}
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