Stephan Richter
4 months ago
25 changed files with 357 additions and 57 deletions
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
||||
/* © SRSoftware 2024 */ |
||||
package de.srsoftware.oidc.api.data; |
||||
|
||||
public enum Permission { MANAGE_CLIENTS } |
||||
public enum Permission { MANAGE_CLIENTS, MANAGE_USERS } |
||||
|
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
function addUser(){ |
||||
var pw = getValue('pw'); |
||||
var pw2 = getValue('pw2'); |
||||
if (pw != pw2) { |
||||
show('pw-mismatch'); |
||||
return; |
||||
} |
||||
var msg = { |
||||
username : getValue('username'), |
||||
realname : getValue('realname'), |
||||
email : getValue('email'), |
||||
password : pw |
||||
}; |
||||
fetch(user_controller+"/add",{ |
||||
method:'POST', |
||||
header: { |
||||
'Content-Type':'application/json' |
||||
}, |
||||
body: JSON.stringify(msg) |
||||
}).then(() => location.reload()) |
||||
} |
||||
|
||||
async function handleUsers(response){ |
||||
if (response.status == UNAUTHORIZED) { |
||||
redirect('login.html?return_to='+encodeURI(window.location.href)) |
||||
return; |
||||
} |
||||
var users = await response.json(); |
||||
var bottom = document.getElementById('bottom'); |
||||
for (let id in users){ |
||||
var row = document.createElement("tr"); |
||||
var user = users[id]; |
||||
row.innerHTML = `<td>${user.username}</td>
|
||||
<td>${user.realname}</td> |
||||
<td>${user.email}</td> |
||||
<td>${id}</td> |
||||
<td> |
||||
<button type="button" onclick="reset_password('${id}')" id="reset-${id}">Reset password</button> |
||||
<button class="danger" onclick="remove('${id}')" type="button">Remove</button> |
||||
</td>`; |
||||
bottom.parentNode.insertBefore(row,bottom); |
||||
} |
||||
} |
||||
|
||||
function handleRemove(response){ |
||||
redirect("users.html"); |
||||
} |
||||
|
||||
function remove(userId){ |
||||
var message = document.getElementById('message').innerHTML; |
||||
if (confirm(message.replace("{}",userId))) { |
||||
fetch(user_controller+"/delete",{ |
||||
method: 'DELETE', |
||||
body : JSON.stringify({ userId : userId }) |
||||
}).then(handleRemove); |
||||
} |
||||
} |
||||
|
||||
function reset_password(userid){ |
||||
fetch(user_controller+"/reset",{ |
||||
method: 'POST', |
||||
body:userid |
||||
}).then(() => { |
||||
disable('reset-'+userid); |
||||
}); |
||||
} |
||||
|
||||
fetch(user_controller+"/list",{method:'POST'}).then(handleUsers); |
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
<html> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<title>Light OIDC</title> |
||||
<script src="scripts/common.js"></script> |
||||
<script src="scripts/user.js"></script> |
||||
<script src="scripts/users.js"></script> |
||||
<link rel="stylesheet" href="style.css" /> |
||||
</head> |
||||
<body> |
||||
<nav></nav> |
||||
<div id="content"> |
||||
<h1>to do…</h1> |
||||
<ul> |
||||
<li><a href="users.html">Users: remove</a></li> |
||||
<li><a href="users.html">Users: send password reset link</a></li> |
||||
<li><a href="login.html">Login: send password reset link</a></li> |
||||
<li><a href="login.html">Login: "remember me" option</a></li> |
||||
</ul> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
<html> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<title>Light OIDC</title> |
||||
<script src="scripts/common.js"></script> |
||||
<script src="scripts/user.js"></script> |
||||
<script src="scripts/users.js"></script> |
||||
<link rel="stylesheet" href="style.css" /> |
||||
</head> |
||||
<body> |
||||
<nav></nav> |
||||
<div id="content"> |
||||
<h1>Users</h1> |
||||
<fieldset> |
||||
<legend>These are users that are registered with LightOIDC:</legend> |
||||
<table class="centered"> |
||||
<tr> |
||||
<th>Username</th> |
||||
<th>Display name</th> |
||||
<th>Email</th> |
||||
<th>ID</th> |
||||
<th>Actions</th> |
||||
</tr> |
||||
<tr id="bottom"> |
||||
<td> |
||||
<input value="" type="text" id="username" placeholder="user name" /> |
||||
</td> |
||||
<td> |
||||
<input value="" type="text" id="realname" placeholder="display name" /> |
||||
</td> |
||||
<td> |
||||
<input value="" type="text" id="email" placeholder="email address" autocomplete="off" /> |
||||
</td> |
||||
<td> |
||||
<input value="" type="password" id="pw" placeholder="password" autocomplete="new-password" /> |
||||
<input value="" type="password" id="pw2" placeholder="repeat password" autocomplete="repeat-password" /> |
||||
</td> |
||||
<td> |
||||
<button onclick="addUser()">Add new user…</button> |
||||
</td> |
||||
</tr> |
||||
|
||||
</table> |
||||
<span class="error" style="display: none" id="pw-mismatch">Passwords do not match!</span> |
||||
</fieldset> |
||||
</div> |
||||
</body> |
||||
</html> |
Loading…
Reference in new issue