-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotp.js
36 lines (30 loc) · 1.01 KB
/
otp.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
function sendOTP(){
const email = document.getElementById('email');
const otpverify = document.getElementById('otpVerify')[0];
let otp_val = Math.floor(Math.random()* 10000);
let emailbody = `<h2>Your OTP is </h2>${otp_val}`;
Email.send({
SecureToken : "5e45c602-f882-4ba9-bf4a-d20d707620b4",
To : email.value,
From : "[email protected]",
Subject : "This is the subject",
Body : emailbody,
}).then(
message => {
if(message == 'OK'){
alert('OTP sent ' + email.value);
otpverify.style.display = "flex";
const otp_inp = document.getElementById('otp-inp');
const otp_btn = document.getElementById('otp-btn');
otp_btn.addEventListener('click', () =>{
if(otp_inp.value == otp_val){
alert('Email address verified');
}
else{
alert('Invalid OTP');
}
})
}
}
);
}