Implemented admin authentication

This commit is contained in:
2020-10-25 12:05:47 +01:00
parent 5034d1a1f8
commit 180ee02582
6 changed files with 308 additions and 88 deletions

View File

@@ -7,17 +7,20 @@
thead {
font-weight: bold;
}
#content {
float: right;
width: 100%;
background-color: #F0F0F0;
}
#menu {
float: left;
width: 200px;
margin-left: -200px;
background-color: #CCCCCC;
}
#menu span {
display: block;
}
@@ -29,14 +32,19 @@
{{ block "page-styles" . }}{{ end }}
</head>
<body>
<div id="content">
{{ block "page-content" . }}{{ end }}
</div>
<div id="menu">
<span><a href="./">ShareDAV</a></span>
<span><a href="users">Users</a></span>
<span><a href="shares">Shares</a></span>
</div>
<div style="clear: both;"></div>
<div id="content">
{{ block "page-content" . }}{{ end }}
</div>
<div id="menu">
<span><a href="./">ShareDAV</a></span>
{{ if .SessionUser }}
{{ if eq .SessionUser.Role "admin" }}
<span><a href="users">Users</a></span>
<span><a href="shares">Shares</a></span>
{{ end }}
<span><a href="logout">Logout</a></span>
{{ end }}
</div>
<div style="clear: both;"></div>
</body>
</html>

View File

@@ -1,3 +1,3 @@
{{ define "page-content" }}
Test {{.foo}}
Startpage.
{{ end }}

24
templates/login.html Normal file
View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ShareDAV Login</title>
</head>
<body>
<div>
<form method="post">
<label>
Username: <input name="username"/>
</label>
<label>
Password: <input type="password" name="password">
</label>
<div>
Beware! You need to have cookies enabled for the login to work.<br/>
The cookie will be used solely for keeping the session alive.
</div>
<input type="submit" value="Login"/>
</form>
</div>
</body>
</html>

View File

@@ -21,7 +21,7 @@
{{ define "page-content" }}
<div id="shares">
{{ range $share := . }}
{{ range $share := .ShareInfos }}
<div id="share-{{$share.UUID}}" class="share">
UUID: {{ $share.UUID }} <form style="display: inline-block;" action="delete-share" method="post">
<input type="hidden" name="share" value="{{ $share.UUID }}"/>

View File

@@ -7,7 +7,7 @@
</tr>
</thead>
<tbody>
{{ range $user := .}}<tr>
{{ range $user := .Users }}<tr>
<td>{{ $user.Username }}</td>
<td>{{ $user.Role }}</td>
</tr>{{ end }}