Commit b4f1193f authored by Robert Czechowski's avatar Robert Czechowski Committed by Robert Czechowski
Browse files

Admin page: Add link to admin page for admin

parent 8a358ae0
...@@ -49,6 +49,9 @@ fn fill_user_data(session: &SessionUser, data: &mut json_val::Map<String, serde_ ...@@ -49,6 +49,9 @@ fn fill_user_data(session: &SessionUser, data: &mut json_val::Map<String, serde_
if session.is_logged_in() { if session.is_logged_in() {
data.insert("logged_in".to_string(), to_json(&true)); data.insert("logged_in".to_string(), to_json(&true));
} }
if session.is_admin() {
data.insert("admin".to_string(), to_json(&true));
}
data.insert("username".to_string(), to_json(&session.username)); data.insert("username".to_string(), to_json(&session.username));
data.insert("firstname".to_string(), to_json(&session.firstname)); data.insert("firstname".to_string(), to_json(&session.firstname));
data.insert("lastname".to_string(), to_json(&session.lastname)); data.insert("lastname".to_string(), to_json(&session.lastname));
......
...@@ -259,6 +259,10 @@ impl SessionUser { ...@@ -259,6 +259,10 @@ impl SessionUser {
(self.password.is_some() || self.logincode.is_some() || self.oauth_foreign_id.is_some()) && self.is_alive() (self.password.is_some() || self.logincode.is_some() || self.oauth_foreign_id.is_some()) && self.is_alive()
} }
pub fn is_admin(&self) -> bool {
self.id == 1
}
pub fn ensure_alive(self) -> Option<Self> { pub fn ensure_alive(self) -> Option<Self> {
if self.is_alive() { if self.is_alive() {
Some(self) Some(self)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<p> <p>
<form action="/admin/user/" method="post"> <form action="/admin/user/" method="post">
Vorname:<br> Vorname:<br>
<input type="text" name="firstname"> <input type="text" name="firstname" value="%">
<br> <br>
Nachname:<br> Nachname:<br>
<input type="text" name="lastname" autofocus> <input type="text" name="lastname" autofocus>
......
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
<a href="/group/" class="button is-warning is-small">&nbsp; Gruppenverwaltung</a> <a href="/group/" class="button is-warning is-small">&nbsp; Gruppenverwaltung</a>
<a href="/teacher" class="button is-primary is-small">👨‍🏫 &nbsp; Lehrer-Informationen</a> <a href="/teacher" class="button is-primary is-small">👨‍🏫 &nbsp; Lehrer-Informationen</a>
{{/if}} {{/if}}
{{#if admin}}
<a href="/admin/" class="button is-warning is-small">&nbsp; Administration</a>
{{/if}}
</div> </div>
</div> </div>
{{/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