-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResetPasswordScreen.js
57 lines (48 loc) · 1.61 KB
/
ResetPasswordScreen.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
function ResetScreen()
{
(function(){
let locators=uiController.locatorUpdate();
let resetEmail;
locators.ResetPass.addEventListener('click',async ()=>{
resetPassword();
})
displayMessage.keyHandler=keyHandler;
window.addEventListener('keypress',displayMessage.keyHandler);
async function resetPassword()
{
resetEmail=locators.SignUpEmail.value;
if(resetEmail==='' || resetEmail.search(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/img)===-1 )
{
displayMessage.errorDisplay('Valid email required');
}
else
{
displayMessage.spinnerDisplay();
try{
await $.post('https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=Your firebase api key',
{requestType:'PASSWORD_RESET',email:resetEmail}).done((data)=>{
//console.log(data)
})
}
catch(error)
{
}
window.removeEventListener('keypress',displayMessage.keyHandler);
window.history.pushState({},null,'/');
locators.container.innerHTML=templates['root'];
locators=uiController.locatorUpdate();
locators.Banner.textContent='You will receive an email for resetting password if you are already registered';
locators.SuccessBanner.style.display='block';
router.routes[window.location.pathname].path();
displayMessage.spinnerHide();
}
}
function keyHandler(e)
{
if(e.keyCode===13 || e.which===13)
{
resetPassword();
}
}
})()
}