Commit 910aa44f authored by Robert Czechowski's avatar Robert Czechowski
Browse files

Show index/login page even with oauth not configured

parent 0d7bdd2b
...@@ -18,7 +18,7 @@ pub fn blaa() -> (String, json_val::Map<String, json_val::Value>) { ...@@ -18,7 +18,7 @@ pub fn blaa() -> (String, json_val::Map<String, json_val::Value>) {
("greeting".to_owned(), data) ("greeting".to_owned(), data)
} }
pub fn index<T: MedalConnection>(conn: &T, session_token: Option<String>, (self_url, oauth_url): (String, String)) -> (String, json_val::Map<String, json_val::Value>) { pub fn index<T: MedalConnection>(conn: &T, session_token: Option<String>, (self_url, oauth_url): (Option<String>, Option<String>)) -> (String, json_val::Map<String, json_val::Value>) {
let mut data = json_val::Map::new(); let mut data = json_val::Map::new();
//let mut contests = Vec::new(); //let mut contests = Vec::new();
......
...@@ -218,11 +218,7 @@ fn greet_personal(req: &mut Request) -> IronResult<Response> { ...@@ -218,11 +218,7 @@ fn greet_personal(req: &mut Request) -> IronResult<Response> {
let (self_url, oauth_url) = { let (self_url, oauth_url) = {
let mutex = req.get::<Write<SharedConfiguration>>().unwrap(); let mutex = req.get::<Write<SharedConfiguration>>().unwrap();
let config = mutex.lock().unwrap_or_else(|e| e.into_inner()); let config = mutex.lock().unwrap_or_else(|e| e.into_inner());
if let (Some(su), Some(ou)) = (&config.self_url, &config.oauth_url) { (config.self_url.clone(), config.oauth_url.clone())
(su.clone(), ou.clone())
} else {
return Ok(Response::with(iron::status::NotFound)) // TODO: Remove OAuth Link if OAuth not available
}
}; };
let (template, data) = { let (template, data) = {
...@@ -300,11 +296,7 @@ fn login(req: &mut Request) -> IronResult<Response> { ...@@ -300,11 +296,7 @@ fn login(req: &mut Request) -> IronResult<Response> {
let (self_url, oauth_url) = { let (self_url, oauth_url) = {
let mutex = req.get::<Write<SharedConfiguration>>().unwrap(); let mutex = req.get::<Write<SharedConfiguration>>().unwrap();
let config = mutex.lock().unwrap_or_else(|e| e.into_inner()); let config = mutex.lock().unwrap_or_else(|e| e.into_inner());
if let (Some(su), Some(ou)) = (&config.self_url, &config.oauth_url) { (config.self_url.clone(), config.oauth_url.clone())
(su.clone(), ou.clone())
} else {
return Ok(Response::with(iron::status::NotFound)) // TODO: Remove OAuth Link if OAuth not available
}
}; };
let mut data = json_val::Map::new(); let mut data = json_val::Map::new();
......
...@@ -3,13 +3,17 @@ ...@@ -3,13 +3,17 @@
<div style="display:inline;float:right;text-align:right;"> <div style="display:inline;float:right;text-align:right;">
{{#if logged_in}} {{#if logged_in}}
Eingeloggt als <em>{{ username }}</em> Eingeloggt als <em>{{ username }}</em>
{{#if firstname}} {{#if firstname}}
{{#if lastname}} {{#if lastname}}
({{firstname}} {{lastname}}) ({{firstname}} {{lastname}})
{{/if}}{{/if}} {{/if}}
{{/if}}
{{#if teacher}} {{#if teacher}}
[Lehrer] [Lehrer]
{{/if}} {{/if}}
<a href="/logout">Logout</a> <a href="/logout">Logout</a>
{{else}} {{else}}
<form action="login" method="post"> <form action="login" method="post">
...@@ -27,7 +31,12 @@ Eingeloggt als <em>{{ username }}</em> ...@@ -27,7 +31,12 @@ Eingeloggt als <em>{{ username }}</em>
<input type="submit" value="log in"> <input type="submit" value="log in">
</form> </form>
{{#if oauth_url}}
{{#if self_url}}
<a href="{{ oauth_url }}{{ self_url }}/oauth">PMS-Login für Lehrer</a> <a href="{{ oauth_url }}{{ self_url }}/oauth">PMS-Login für Lehrer</a>
{{/if}}
{{/if}}
{{/if}} {{/if}}
</div> </div>
......
...@@ -23,5 +23,12 @@ ...@@ -23,5 +23,12 @@
</form> </form>
<p>
<a href="{{ oauth_url }}{{ self_url }}/oauth">PMS-Login</a>
{{#if oauth_url}}
{{#if self_url}}
<p><a href="{{ oauth_url }}{{ self_url }}/oauth">PMS-Login</a>
{{/if}}
{{/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