generated from Men-In-Brown/Linkr-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount.html
More file actions
110 lines (103 loc) · 4.23 KB
/
account.html
File metadata and controls
110 lines (103 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<html>
<head>
<title>Login and Signup</title>
</head>
<body>
<h2>Login</h2>
<form id="loginForm">
<label for="loginUsername">Username:</label>
<input type="text" id="loginUsername" name="username" required>
<br>
<label for="loginPassword">Password:</label>
<input type="password" id="loginPassword" name="password" required>
<br>
<label for="patPassword">Pat - if you have one:</label>
<input type="password" id="patpass" name="patPassword" required>
<button type="submit">Login</button>
</form>
<h2>Signup</h2>
<form id="signupForm">
<label for="signupEmail">Email:</label>
<input type="email" id="signupEmail" name="email" required>
<br>
<label for="signupUsername">Username:</label>
<input type="text" id="signupUsername" name="username" required>
<br>
<label for="signupPassword">Password:</label>
<input type="password" id="signupPassword" name="password" required>
<br>
<label for="signupName">Name:</label>
<input type="text" id="signupName" name="name" required>
<br>
<label for="signupRole">Role:</label>
<select id="signupRole" name="role" required>
<option value="USER">User</option>
<option value="ADMIN">Admin</option>
<!-- Add other roles as needed -->
</select>
<br>
<label for="signupSubjects">Subjects:</label>
<input type="text" id="signupSubjects" name="subjects" placeholder="Enter subjects separated by commas" required>
<br>
<button type="submit">Signup</button>
</form>
<script>
document.getElementById('loginForm').addEventListener('submit', function(event) {
event.preventDefault();
const username = document.getElementById('loginUsername').value;
const password = document.getElementById('loginPassword').value;
const pat = document.getElementById('patpass').value;
fetch("https://schaal.stu.nighthawkcodingsociety.comlogin", requestOptions, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ usn: username, password: password, pat: pat})
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('Login successful!');
// Redirect or handle successful login
} else {
alert('Login failed!');
}
})
.catch(error => console.error('Error:', error));
});
document.getElementById('signupForm').addEventListener('submit', function(event) {
event.preventDefault();
const email = document.getElementById('signupEmail').value;
const username = document.getElementById('signupUsername').value;
const password = document.getElementById('signupPassword').value;
const name = document.getElementById('signupName').value;
const role = document.getElementById('signupRole').value;
const subjects = document.getElementById('signupSubjects').value.split(',');
fetch("https://schaal.stu.nighthawkcodingsociety.comsignup", {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email,
usn: username,
password: password,
name: name,
roles: [{ roleName: role }],
subjectsOfInterest: subjects.map(subject => subject.trim())
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('Signup successful!');
// Redirect or handle successful signup
} else {
alert('Signup failed!');
}
})
.catch(error => console.error('Error:', error));
});
</script>
</body>
</html>