Implement Two-factor authentication

This commit is contained in:
BlameDylan 2015-12-10 19:40:59 -06:00
parent 59ff1ebbe6
commit 4585753d04
6 changed files with 102 additions and 26 deletions

View file

@ -12,6 +12,7 @@ return [
'password' => 'Password',
'email' => 'Email',
'whoops' => 'Whoops',
'failed' => 'Your request could not be processed. Please try again later.',
'success' => 'Success',
'location' => 'Location',
'node' => 'Node',

View file

@ -72,6 +72,7 @@ return [
'array' => 'The :attribute must contain :size items.',
],
'string' => 'The :attribute must be a string.',
'totp' => 'The totp token is invalid. Did it expire?',
'timezone' => 'The :attribute must be a valid zone.',
'unique' => 'The :attribute has already been taken.',
'url' => 'The :attribute format is invalid.',

View file

@ -75,31 +75,34 @@
</div>
<div class="col-md-3"></div>
<script type="text/javascript">
$(document).ready(function(){
// $("#login-form").submit(function(event){
// var check_email = $("#email").val();
// $.ajax({
// type: "POST",
// url: "/auth/login/totp",
// async: false,
// data: { check: check_email },
// success: function(data){
// if(data == 'true'){
// $("#openTOTP").modal('show');
// $('#openTOTP').on('shown.bs.modal', function(){
// $("#totp_token").focus();
// })
// event.preventDefault();
// }else{
// $(this).submit();
// }
// }
// });
// });
// $("#totp-form").submit(function(){
// $('#login-form :input').not(':submit').clone().hide().appendTo('#totp-form');
// return true;
// });
$(document).ready(function() {
$("#login-form").one("submit", function(event) {
event.preventDefault();
var check_email = $("#email").val();
$.ajax({
type: 'POST',
url: '/auth/login/totp',
data: {
email: check_email,
_token: '{!! csrf_token() !!}'
}
}).done(function(data) {
if (typeof data.id !== 'undefined') {
$("#openTOTP").modal('show');
$('#openTOTP').on('shown.bs.modal', function() {
$("#totp_token").focus();
});
} else {
$("#login-form").submit();
}
}).fail(function(jqXHR) {
alert("{{ trans('strings.failed') }}");
});
});
$("#totp-form").submit(function() {
$('#login-form :input').not(':submit').clone().hide().appendTo('#totp-form');
return true;
});
});
</script>
@endsection