ciyidogan commited on
Commit
1a9b474
·
verified ·
1 Parent(s): d917409

Create auth.js

Browse files
Files changed (1) hide show
  1. static/auth.js +16 -0
static/auth.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function login() {
2
+ const username = document.getElementById('login-username').value;
3
+ const password = document.getElementById('login-password').value;
4
+ apiPost('/auth/login', { username, password })
5
+ .then(data => showResult('login-result', data))
6
+ .catch(err => console.error(err));
7
+ }
8
+
9
+ function changePassword() {
10
+ const username = document.getElementById('change-username').value;
11
+ const oldPassword = document.getElementById('old-password').value;
12
+ const newPassword = document.getElementById('new-password').value;
13
+ apiPost('/auth/change_password', { username, old_password: oldPassword, new_password: newPassword })
14
+ .then(data => showResult('change-password-result', data))
15
+ .catch(err => console.error(err));
16
+ }