-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from Coderberg/2.x
2.x
- Loading branch information
Showing
111 changed files
with
2,373 additions
and
751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
(function ($) { | ||
|
||
'use strict'; | ||
|
||
const $phone = $('#phone'); | ||
const $email = $('#email'); | ||
|
||
$('body').append(`<div class="bottom-bar"> | ||
<a class="btn-right" href="${$phone.attr('href')}">${$phone.attr('title')}</a> | ||
<a class="btn-left" href="${$email.attr('href')}">${$email.attr('title')}</a> | ||
<a class="btn-right" href="${$phone.attr( | ||
'href' | ||
)}">${$phone.attr('title')}</a> | ||
<a class="btn-left" href="${$email.attr( | ||
'href' | ||
)}">${$email.attr('title')}</a> | ||
</div>`); | ||
|
||
})(window.jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
(function ($) { | ||
'use strict'; | ||
|
||
const $form = $('#generate_google_auth_secret'); | ||
const token = $('[name="auth_token"]').val(); | ||
const $secret = $('[name="generatedSecret"]'); | ||
const $authentication_code = $('[name="authentication_code"]'); | ||
|
||
// Open modal window | ||
$('#setUpAuthenticatorButton').click(function () { | ||
if ($form.data('generate-new-secret') === true) { | ||
$.ajax({ | ||
method: 'GET', | ||
url: '/en/user/google_authenticator_code', | ||
data: { csrf_token: token } | ||
}).done(function (response) { | ||
const { secret, qr_code } = response; | ||
const image = new Image(); | ||
image.src = qr_code; | ||
|
||
$secret.val(secret); | ||
$('#generatedQrCode').html(image); | ||
$('#generatedSecret').html(secret); | ||
}); | ||
} | ||
}); | ||
|
||
// Enable 2fa | ||
$('#enable2fa').click(function () { | ||
let authentication_code = $authentication_code.val().trim(); | ||
|
||
if (!authentication_code) { | ||
$authentication_code.addClass('is-invalid').focus(); | ||
|
||
return; | ||
} | ||
|
||
$.ajax({ | ||
method: 'PUT', | ||
url: $form.attr('action'), | ||
data: { | ||
csrf_token: token, | ||
secret: $secret.val(), | ||
authentication_code: authentication_code | ||
} | ||
}) | ||
.done(function () { | ||
location.reload(); | ||
}) | ||
.fail(function (data) { | ||
showError(data.responseJSON.message); | ||
}); | ||
}); | ||
|
||
// Disable 2fa | ||
$('#disable2fa').click(function () { | ||
$.ajax({ | ||
method: 'DELETE', | ||
url: $form.attr('action'), | ||
data: { csrf_token: token } | ||
}) | ||
.done(function () { | ||
location.reload(); | ||
}) | ||
.fail(function () { | ||
location.reload(); | ||
}); | ||
}); | ||
|
||
$authentication_code.keyup(function () { | ||
$(this).removeClass('is-invalid'); | ||
}); | ||
|
||
// Reset form state | ||
$('#setUpAuthenticator').on('hidden.bs.modal', function () { | ||
resetFormState(); | ||
}); | ||
|
||
function resetFormState() { | ||
$authentication_code.val('').removeClass('is-invalid'); | ||
$('#twoFactorAuthErrorMessage').text('').addClass('d-none'); | ||
} | ||
|
||
function showError(message) { | ||
$('#twoFactorAuthErrorMessage') | ||
.text(message) | ||
.removeClass('d-none'); | ||
} | ||
})(window.jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.security-buttons a i { | ||
background-color: #fff; | ||
padding: 20px; | ||
border-radius: 50%; | ||
color: #BDC3C7; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.