Skip to content

Commit 394b30d

Browse files
authored
Create Phone.js
1 parent 5ae78db commit 394b30d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Phone.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
window.onload = function () {
2+
render();
3+
};
4+
function render() {
5+
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
6+
recaptchaVerifier.render();
7+
}
8+
function phoneAuth() {
9+
//get the number
10+
var number = document.getElementById('number').value;
11+
//phone number authentication function of firebase
12+
//it takes two parameter first one is number,,,second one is recaptcha
13+
firebase.auth().signInWithPhoneNumber(number, window.recaptchaVerifier).then(function (confirmationResult) {
14+
//s is in lowercase
15+
window.confirmationResult = confirmationResult;
16+
coderesult = confirmationResult;
17+
console.log(coderesult);
18+
alert("Message sent");
19+
}).catch(function (error) {
20+
alert(error.message);
21+
});
22+
}
23+
function codeverify() {
24+
var code = document.getElementById('verificationCode').value;
25+
coderesult.confirm(code).then(function (result) {
26+
alert("Successfully registered");
27+
var user = result.user;
28+
console.log(user);
29+
}).catch(function (error) {
30+
alert(error.message);
31+
});
32+
}

0 commit comments

Comments
 (0)