Login leitet Studenten an korrekte Übersicht
This commit is contained in:
1 parent
7c48e66677
commit
1153520f57
1 file changed
+49
-39
+49
-39
@@ -1,50 +1,60 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Login</title>
|
<title>Login</title>
|
||||||
<link rel="stylesheet" href="./lib/basic.css">
|
<link rel="stylesheet" href="./lib/basic.css">
|
||||||
<script src="./auth.js"></script>
|
<script src="./auth.js"></script>
|
||||||
<script src="./lib/basic.js"></script>
|
<script src="./lib/basic.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<input id="username"><br>
|
|
||||||
<input type="password" id="password">
|
|
||||||
|
|
||||||
<button onclick="login()">Submit</button>
|
<input id="username"><br>
|
||||||
|
<input type="password" id="password">
|
||||||
<script>
|
|
||||||
|
|
||||||
const couchDB = new CouchDB();
|
<button onclick="login()">Submit</button>
|
||||||
|
|
||||||
async function getData() {
|
<script>
|
||||||
let res = await couchDB.get("users");
|
|
||||||
if (!res) res = {};
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function login() {
|
const couchDB = new CouchDB();
|
||||||
const data = await getData();
|
|
||||||
const username = getId("username").value.toLowerCase();
|
async function getData() {
|
||||||
const password = getId("password").value;
|
let res = await couchDB.get("users");
|
||||||
|
if (!res) res = {};
|
||||||
const user = data[username];
|
return res;
|
||||||
//{"turtle":{"password": "password","level":1}}
|
}
|
||||||
if (user == undefined) {
|
|
||||||
alert("Falscher Nutzername!");
|
async function login() {
|
||||||
return;
|
const data = await getData();
|
||||||
}
|
const username = getId("username").value.toLowerCase();
|
||||||
if (user.password != password) {
|
const password = getId("password").value;
|
||||||
alert("Falsches Passwort!");
|
|
||||||
return;
|
const user = data[username];
|
||||||
}
|
//{"turtle":{"password": "password","level":1}}
|
||||||
|
if (user == undefined) {
|
||||||
location.href = "./prof/uebersicht.html?user=" + username;
|
alert("Falscher Nutzername!");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
if (user.password != password) {
|
||||||
|
alert("Falsches Passwort!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (user.role) {
|
||||||
|
case "professor":
|
||||||
|
location.href = "./prof/uebersicht.html?user=" + username;
|
||||||
|
return;
|
||||||
|
case "student":
|
||||||
|
location.href = "./student/uebersicht.html?user=" + username;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
|
||||||
|
</html>
|
||||||
Reference in new issue
Block a user