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