|
@@ -1,12 +1,147 @@
|
1
|
|
-function showOtpBox() {
|
2
|
|
- document.getElementById('div_ForgotPswd').style.display = 'none';
|
3
|
|
- document.getElementById('modal_Otp').style.display = 'block';
|
|
1
|
+const serverUrl = 'http://localhost:3088/';
|
|
2
|
+let otpid;
|
|
3
|
+let sendotp;
|
|
4
|
+let unibaseid;
|
|
5
|
+async function showOtpBox() {
|
|
6
|
+ let inputdetails = document.getElementById('txt_PhoneorMail').value;
|
|
7
|
+
|
|
8
|
+ let sendnumber = await fetch(serverUrl + 'account/getuserbyphoneormail/'+inputdetails+'/'+inputdetails)
|
|
9
|
+ let textdata = await sendnumber.json();
|
|
10
|
+ if(textdata.result != null){
|
|
11
|
+ unibaseid = textdata.result.unibaseId;
|
|
12
|
+ var myHeaders = new Headers();
|
|
13
|
+ myHeaders.append("Content-Type", "application/json");
|
|
14
|
+
|
|
15
|
+ var raw = JSON.stringify({
|
|
16
|
+ "FirstName": "",
|
|
17
|
+ "LastName": "",
|
|
18
|
+ "ContactNumber": "",
|
|
19
|
+ "Email": "",
|
|
20
|
+ "TenantName": "",
|
|
21
|
+ "ContactOrEmail": inputdetails,
|
|
22
|
+ "IsSignup": false,
|
|
23
|
+ "IsRegisterUser": false,
|
|
24
|
+ "IsForgotPswd": true,
|
|
25
|
+ "UnibaseId": unibaseid,
|
|
26
|
+ "OtpId": 0,
|
|
27
|
+ "UserOtp": ""
|
|
28
|
+ });
|
|
29
|
+
|
|
30
|
+ var requestOptions = {
|
|
31
|
+ method: 'POST',
|
|
32
|
+ headers: myHeaders,
|
|
33
|
+ body: raw,
|
|
34
|
+ redirect: 'follow'
|
|
35
|
+ };
|
|
36
|
+
|
|
37
|
+ fetch(serverUrl + 'account/sendotp', requestOptions)
|
|
38
|
+ .then(response => response.text())
|
|
39
|
+ .then(function(result){
|
|
40
|
+ optid = result;
|
|
41
|
+ document.getElementById('div_ForgotPswd').style.display = 'none';
|
|
42
|
+ document.getElementById('modal_Otp').style.display = 'block';
|
|
43
|
+ document.getElementById('div_ValidationSummary').innerHTML = "";
|
|
44
|
+ })
|
|
45
|
+ .catch(error => console.log('error', error));
|
|
46
|
+ }
|
|
47
|
+ else{
|
|
48
|
+ let html = '<div class="p-2"><span class="error-warning">Error !</span> Email/Phonenumber does not exist</div>' ;
|
|
49
|
+ document.getElementById('div_ValidationSummary').innerHTML = "";
|
|
50
|
+ let error = document.getElementById('div_ValidationSummary');
|
|
51
|
+ error.insertAdjacentHTML('beforeend',html);
|
|
52
|
+ }
|
4
|
53
|
}
|
5
|
|
-function showPasswordBox() {
|
6
|
|
- document.getElementById('modal_Otp').style.display = 'none';
|
7
|
|
- document.getElementById('div_ResetPswd').style.display = 'block';
|
|
54
|
+
|
|
55
|
+/*verify otp*/
|
|
56
|
+ async function showPasswordBox() {
|
|
57
|
+ let inputdetails = document.getElementById('txt_Code').value;
|
|
58
|
+ if(inputdetails.length > 0){
|
|
59
|
+ var myHeaders = new Headers();
|
|
60
|
+ myHeaders.append("Content-Type", "application/json");
|
|
61
|
+ var raw = JSON.stringify({
|
|
62
|
+ "FirstName": "",
|
|
63
|
+ "LastName": "",
|
|
64
|
+ "ContactNumber": "",
|
|
65
|
+ "Email": "",
|
|
66
|
+ "TenantName": "",
|
|
67
|
+ "ContactOrEmail": "",
|
|
68
|
+ "IsForgotPswd": false,
|
|
69
|
+ "IsRegisterUser": false,
|
|
70
|
+ "IsSignup": true,
|
|
71
|
+ "UnibaseId": "",
|
|
72
|
+ "OtpId": optid,
|
|
73
|
+ "UserOtp": inputdetails
|
|
74
|
+ });
|
|
75
|
+
|
|
76
|
+ var requestOptions = {
|
|
77
|
+ method: 'POST',
|
|
78
|
+ headers: myHeaders,
|
|
79
|
+ body: raw,
|
|
80
|
+ redirect: 'follow'
|
|
81
|
+ };
|
|
82
|
+
|
|
83
|
+ fetch(serverUrl + 'account/verifyotp', requestOptions)
|
|
84
|
+ .then(response => response.text())
|
|
85
|
+ .then(function(result){
|
|
86
|
+ let data = JSON.parse(result);
|
|
87
|
+ if(data.result.contactConfirmed == true){
|
|
88
|
+ document.getElementById('modal_Otp').style.display = 'none';
|
|
89
|
+ document.getElementById('div_ResetPswd').style.display = 'block';
|
|
90
|
+ document.getElementById('div_ValidationSummary').innerHTML = "";
|
|
91
|
+ }else{
|
|
92
|
+ let html = '<div class="p-2" ><span class="error-warning">Error !</span> Enter Valid OTP</div>' ;
|
|
93
|
+ document.getElementById('div_ValidationSummary').innerHTML = "";
|
|
94
|
+ let error = document.getElementById('div_ValidationSummary');
|
|
95
|
+ error.insertAdjacentHTML('beforeend',html);
|
|
96
|
+ }
|
|
97
|
+ })
|
|
98
|
+ .catch(error => console.log('error', error));
|
|
99
|
+ }else{
|
|
100
|
+
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
8
|
105
|
}
|
9
|
106
|
function showSuccessBox() {
|
10
|
|
- document.getElementById('div_ResetPswd').style.display = 'none';
|
11
|
|
- document.getElementById('div_SuccessMsg').style.display = 'block';
|
12
|
|
-}
|
|
107
|
+ let txt_NewPassword = document.getElementById('txt_NewPassword').value;
|
|
108
|
+ let txt_ConfirmPassword = document.getElementById('txt_ConfirmPassword').value;
|
|
109
|
+ if(txt_NewPassword == txt_ConfirmPassword){
|
|
110
|
+ var myHeaders = new Headers();
|
|
111
|
+myHeaders.append("Content-Type", "application/json");
|
|
112
|
+var raw = JSON.stringify({
|
|
113
|
+ "Password": txt_NewPassword,
|
|
114
|
+ "UserName": unibaseid
|
|
115
|
+});
|
|
116
|
+var requestOptions = {
|
|
117
|
+ method: 'POST',
|
|
118
|
+ headers: myHeaders,
|
|
119
|
+ body: raw,
|
|
120
|
+ redirect: 'follow'
|
|
121
|
+};
|
|
122
|
+fetch(serverUrl + 'account/updatepassword', requestOptions)
|
|
123
|
+ .then(response => response.text())
|
|
124
|
+ .then(function(result){
|
|
125
|
+ let updatepassword = JSON.parse(result);
|
|
126
|
+ let message = updatepassword.message;
|
|
127
|
+ if(message == 'Password Updated Successfully'){
|
|
128
|
+ document.getElementById('div_ValidationSummary').innerHTML = "";
|
|
129
|
+ document.getElementById('div_ResetPswd').style.display = 'none';
|
|
130
|
+ document.getElementById('div_SuccessMsg').style.display = 'block';
|
|
131
|
+ }
|
|
132
|
+ }
|
|
133
|
+ )
|
|
134
|
+ .catch(error => console.log('error', error));
|
|
135
|
+
|
|
136
|
+ }else{
|
|
137
|
+ let html = '<div class="p-2"> <span class="error-warning">Error !</span> Password Does not Match</div>' ;
|
|
138
|
+ document.getElementById('div_ValidationSummary').innerHTML = "";
|
|
139
|
+ let error = document.getElementById('div_ValidationSummary');
|
|
140
|
+ error.insertAdjacentHTML('beforeend',html);
|
|
141
|
+ }
|
|
142
|
+
|
|
143
|
+}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|