-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.js
69 lines (57 loc) · 1.6 KB
/
auth.js
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
class User {
constructor(){
// this.name = n;
}
#checkUsername(username){
let value = username.includes('#') ? false:true
return value
}
#checkPassword(password){
let value = password.length>7?true:false
if(!value){
alert('enter At leat * characters')
}
return value
}
async signup(n,e,u,p,m,d){
let isValidated = this.#checkUsername(u) && this.#checkPassword(p)
if(isValidated){
this.name = n,
this.email = e,
this.username = u,
this.password = p,
this.mobile = m,
this.description = d
let actaul_data = JSON.stringify(this)
try{
let res = await fetch('https://masai-api-mocker.herokuapp.com/auth/register',{
method: 'POST',
body: actaul_data,
headers:{
'Content-Type':'application/json',
},
})
let data = await res.json()
console.log(data);
}catch(err){
console.log(err);
}
}
}
}
let u1 = new User()
// console.log(u1);
// u1.#checkPassword()
function Register(){
function getInputValue(id){
let value =document.getElementById(id).value;
return value;
}
const name = getInputValue('name');
const email = getInputValue('email')
const password = getInputValue('username')
const username = getInputValue('password')
const mobile = getInputValue('mobile')
const description = getInputValue('description')
u1.signup(name,email,username,password,mobile,description)
}