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

Pretty phone for MFA registration #702

Merged
merged 2 commits into from
Sep 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -106,6 +105,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 @@ -195,7 +204,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