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_
if session.is_logged_in() {
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("firstname".to_string(), to_json(&session.firstname));
data.insert("lastname".to_string(), to_json(&session.lastname));
......
......@@ -259,6 +259,10 @@ impl SessionUser {
(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> {
if self.is_alive() {
Some(self)
......
......@@ -4,7 +4,7 @@
<p>
<form action="/admin/user/" method="post">
Vorname:<br>
<input type="text" name="firstname">
<input type="text" name="firstname" value="%">
<br>
Nachname:<br>
<input type="text" name="lastname" autofocus>
......
......@@ -53,6 +53,9 @@
<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>
{{/if}}
{{#if admin}}
<a href="/admin/" class="button is-warning is-small">&nbsp; Administration</a>
{{/if}}
</div>
</div>
{{/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