Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Pretty phone for MFA registration (#702)
Browse files Browse the repository at this point in the history
* Pretty phone for  MFA registration

* better help  text
  • Loading branch information
whaught authored Sep 28, 2020
1 parent 0d8889b commit 4f81505
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions cmd/server/assets/login/register-phone.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@
</p>

<form id="register-form" class="floating-form" action="/" method="POST">
<div class="form-label-group">
<input type="tel" id="phone" name="phone" class="form-control" placeholder="Phone number" required
autofocus />
<label for="phone">Phone number</label>
<div class="form-group">
<input type="tel" id="phone" name="phone" class="form-control" required autofocus />
<small class="form-text text-muted">
Fully qualified phone number beginning with '+'. Standard SMS rates may apply.
You will be asked to confirm a code using this phone number at login.
Standard SMS rates may apply.
</small>
</div>
</div>

<div class="form-label-group">
<input type="text" id="display" name="display" class="form-control" placeholder="Display name" />
<label for="display">Display name</label>
<small class="form-text text-muted">
Name for this phone.
Display name for this phone.
</small>
</div>

Expand Down Expand Up @@ -107,6 +106,16 @@

let verId = ""

// Initialize pretty phone
let phone = document.querySelector('#phone');
let iti = window.intlTelInput(phone, {
nationalMode: true,
{{- if $currentRealm.SMSCountry }}
initialCountry: '{{$currentRealm.SMSCountry}}',
{{- end }}
utilsScript: 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.0/js/utils.js',
});

firebase.auth().onAuthStateChanged(function(user) {
if (!user) {
window.location.assign("/signout");
Expand Down Expand Up @@ -197,7 +206,7 @@
user.multiFactor.getSession().then(function(multiFactorSession) {
// Specify the phone number and pass the MFA session.
var phoneInfoOptions = {
phoneNumber: $phone.val(),
phoneNumber: iti.getNumber(),
session: multiFactorSession
};
var phoneAuthProvider = new firebase.auth.PhoneAuthProvider();
Expand Down

0 comments on commit 4f81505

Please sign in to comment.