2024-07-05 17:11:08 +08:00
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
2024-07-17 09:04:52 +08:00
|
|
|
|
<#import "./common/common.macro.ftl" as netCommon>
|
|
|
|
|
<@netCommon.commonStyle />
|
2024-07-05 17:11:08 +08:00
|
|
|
|
<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/iCheck/square/blue.css">
|
2024-07-17 09:04:52 +08:00
|
|
|
|
<title>${I18n.admin_name}</title>
|
2024-07-05 17:11:08 +08:00
|
|
|
|
</head>
|
|
|
|
|
<body class="hold-transition login-page">
|
2024-07-17 09:04:52 +08:00
|
|
|
|
<#-- <div class="login-box">-->
|
|
|
|
|
<#-- <div class="login-logo">-->
|
|
|
|
|
<#-- <a><b>XXL</b>JOB</a>-->
|
|
|
|
|
<#-- </div>-->
|
|
|
|
|
<#-- <form id="loginForm" method="post" >-->
|
|
|
|
|
<#-- <div class="login-box-body">-->
|
|
|
|
|
<#-- <p class="login-box-msg">${I18n.admin_name}</p>-->
|
|
|
|
|
<#-- <div class="form-group has-feedback">-->
|
|
|
|
|
<#-- <input type="text" name="userName" class="form-control" placeholder="${I18n.login_username_placeholder}" maxlength="18" >-->
|
|
|
|
|
<#-- <span class="glyphicon glyphicon-envelope form-control-feedback"></span>-->
|
|
|
|
|
<#-- </div>-->
|
|
|
|
|
<#-- <div class="form-group has-feedback">-->
|
|
|
|
|
<#-- <input type="password" name="password" class="form-control" placeholder="${I18n.login_password_placeholder}" maxlength="18" >-->
|
|
|
|
|
<#-- <span class="glyphicon glyphicon-lock form-control-feedback"></span>-->
|
|
|
|
|
<#-- </div>-->
|
|
|
|
|
<#-- <div class="row">-->
|
|
|
|
|
<#-- <div class="col-xs-8">-->
|
|
|
|
|
<#-- <div class="checkbox icheck">-->
|
|
|
|
|
<#-- <label>-->
|
|
|
|
|
<#-- <input type="checkbox" name="ifRemember" > ${I18n.login_remember_me}-->
|
|
|
|
|
<#-- </label>-->
|
|
|
|
|
<#-- </div>-->
|
|
|
|
|
<#-- </div><!-- /.col –>-->
|
|
|
|
|
<#-- <div class="col-xs-4">-->
|
|
|
|
|
<#-- <button type="submit" class="btn btn-primary btn-block btn-flat">${I18n.login_btn}</button>-->
|
|
|
|
|
<#-- </div>-->
|
|
|
|
|
<#-- </div>-->
|
|
|
|
|
<#-- </div>-->
|
|
|
|
|
<#-- </form>-->
|
|
|
|
|
<#-- </div>-->
|
2024-07-05 17:11:08 +08:00
|
|
|
|
<@netCommon.commonScript />
|
2024-07-17 09:04:52 +08:00
|
|
|
|
<#--<script src="${request.contextPath}/static/adminlte/plugins/iCheck/icheck.min.js"></script>-->
|
|
|
|
|
<#--<script src="${request.contextPath}/static/js/login.1.js"></script>-->
|
|
|
|
|
<script src="${request.contextPath}/static/adminlte/bower_components/jquery/jquery.min.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
/**
|
|
|
|
|
* 跳转单点登录
|
|
|
|
|
*/
|
|
|
|
|
function ssoLogin() {
|
|
|
|
|
const clientId = 'ludu-job-admin'; // 可以改写成,你的 clientId
|
|
|
|
|
const redirectUri = encodeURIComponent('http://127.0.0.1:9090/xxl-job-admin/toLogin'); // 注意,需要使用 encodeURIComponent 编码地址
|
|
|
|
|
const responseType = 'code'; // 1)授权码模式,对应 code;2)简化模式,对应 token
|
|
|
|
|
window.location.href = 'http://127.0.0.1:80/sso?client_id=' + clientId
|
|
|
|
|
+ '&redirect_uri=' + redirectUri
|
|
|
|
|
+ '&response_type=' + responseType;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 12:01:08 +08:00
|
|
|
|
// 读取 cookie
|
|
|
|
|
const accessToken = document.cookie
|
|
|
|
|
.replace(/(?:(?:^|.*;\s*)ACCESS_TOKEN\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
|
|
|
|
const refreshToken = document.cookie
|
|
|
|
|
.replace(/(?:(?:^|.*;\s*)REFRESH_TOKEN\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
2024-07-17 09:04:52 +08:00
|
|
|
|
// 情况一:未登录
|
|
|
|
|
if (!accessToken) {
|
|
|
|
|
// 获取 URL 中的查询参数
|
|
|
|
|
let urlParams = new URLSearchParams(window.location.search);
|
|
|
|
|
// 获取 code 参数的值
|
|
|
|
|
let code = urlParams.get('code');
|
|
|
|
|
if (!code) {
|
|
|
|
|
ssoLogin();
|
|
|
|
|
} else {
|
|
|
|
|
// 提交
|
|
|
|
|
const redirectUri = 'http://127.0.0.1:9090/xxl-job-admin/toLogin'; // 需要修改成,你回调的地址,就是在 index.html 拼接的 redirectUri
|
|
|
|
|
$.ajax({
|
2024-07-17 12:01:08 +08:00
|
|
|
|
url: "http://127.0.0.1:9090/xxl-job-admin/auth/login-by-code?code=" + code
|
2024-07-17 09:04:52 +08:00
|
|
|
|
+ '&redirectUri=' + redirectUri,
|
|
|
|
|
method: 'POST',
|
2024-07-17 12:01:08 +08:00
|
|
|
|
success: function (result) {
|
2024-07-17 09:04:52 +08:00
|
|
|
|
if (result.code !== 0) {
|
|
|
|
|
// layer.open({
|
|
|
|
|
// title: I18n.system_tips,
|
|
|
|
|
// btn: [ I18n.system_ok ],
|
|
|
|
|
// content: (data.msg || (I18n.jobgroup_del + I18n.system_fail)),
|
|
|
|
|
// icon: '2'
|
|
|
|
|
// });
|
|
|
|
|
alert('获得访问令牌失败,原因:' + result.msg)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-07-17 12:01:08 +08:00
|
|
|
|
// 设置cookie
|
2024-07-17 15:52:20 +08:00
|
|
|
|
document.cookie = "ACCESS_TOKEN=" + result.data.access_token + "; max-age=" + (result.data.expires_in - 20) + "; path=/xxl-job-admin";
|
2024-07-17 12:01:08 +08:00
|
|
|
|
document.cookie = "REFRESH_TOKEN=" + result.data.refresh_token + "; max-age=43000; path=/xxl-job-admin";
|
2024-07-17 09:04:52 +08:00
|
|
|
|
// 跳转回首页
|
|
|
|
|
window.location.href = '/xxl-job-admin';
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 情况三:已登录
|
|
|
|
|
else {
|
|
|
|
|
window.location.href = '/xxl-job-admin';
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2024-07-05 17:11:08 +08:00
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|