Files
EasyAdmin8/public/static/admin/js/login.js
wolfcode 75c668b966 feat(auth): 新增谷歌验证码登录 implement Google Authenticator support for two-factor authentication
- Add Google Authenticator integration for enhanced login security-Update admin edit page to include login type selection
- Modify login process to support two-factor authentication
- Add new database fields for login type and GA secret
- Update client-side JavaScript to handle GA code input and validation
2024-11-12 10:51:48 +08:00

56 lines
2.1 KiB
PHP

define(["jquery", "easy-admin"], function ($, ea) {
return {
index: function () {
if (top.location !== self.location) {
top.location = self.location;
}
$(function () {
if (backgroundUrl) {
$('.container').css('background', 'url(' + backgroundUrl + ') 0% 0% / cover no-repeat')
}
$('.bind-password').on('click', function () {
if ($(this).hasClass('icon-5')) {
$(this).removeClass('icon-5');
$("input[name='password']").attr('type', 'password');
} else {
$(this).addClass('icon-5');
$("input[name='password']").attr('type', 'text');
}
});
$('.icon-nocheck').on('click', function () {
if ($(this).hasClass('icon-check')) {
$(this).removeClass('icon-check');
} else {
$(this).addClass('icon-check');
}
});
$('.login-tip').on('click', function () {
$('.icon-nocheck').click();
});
ea.listen(function (data) {
data['keep_login'] = $('.icon-nocheck').hasClass('icon-check') ? 1 : 0;
return data;
}, function (res) {
ea.msg.success(res.msg, function () {
window.location = ea.url('index');
})
}, function (res) {
let data = res.data
if (data.is_ga_code) {
let elem = $('#gaCode')
elem.removeClass('layui-hide');
elem.find('input').focus()
}
ea.msg.error(res.msg, function () {
$('#refreshCaptcha').trigger("click");
});
});
});
},
};
});