105 lines
4.7 KiB
Plaintext
105 lines
4.7 KiB
Plaintext
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<#import "./common/common.macro.ftl" as netCommon>
|
||
<@netCommon.commonStyle />
|
||
<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/iCheck/square/blue.css">
|
||
<title>${I18n.admin_name}</title>
|
||
</head>
|
||
<body class="hold-transition login-page">
|
||
<#-- <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>-->
|
||
<@netCommon.commonScript />
|
||
<#--<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('https://mt.ptzykjgs.com/xxl-job-admin/toLogin'); // 注意,需要使用 encodeURIComponent 编码地址
|
||
const responseType = 'code'; // 1)授权码模式,对应 code;2)简化模式,对应 token
|
||
window.location.href = 'https://mt.ptzykjgs.com/admin/sso?client_id=' + clientId
|
||
+ '&redirect_uri=' + redirectUri
|
||
+ '&response_type=' + responseType;
|
||
}
|
||
|
||
// 读取 cookie
|
||
const accessToken = document.cookie
|
||
.replace(/(?:(?:^|.*;\s*)ACCESS_TOKEN\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||
const refreshToken = document.cookie
|
||
.replace(/(?:(?:^|.*;\s*)REFRESH_TOKEN\s*\=\s*([^;]*).*$)|^.*$/, "$1");
|
||
// 情况一:未登录
|
||
if (!accessToken) {
|
||
// 获取 URL 中的查询参数
|
||
let urlParams = new URLSearchParams(window.location.search);
|
||
// 获取 code 参数的值
|
||
let code = urlParams.get('code');
|
||
if (!code) {
|
||
ssoLogin();
|
||
} else {
|
||
// 提交
|
||
const redirectUri = 'https://mt.ptzykjgs.com/xxl-job-admin/toLogin'; // 需要修改成,你回调的地址,就是在 index.html 拼接的 redirectUri
|
||
$.ajax({
|
||
url: "https://mt.ptzykjgs.com/xxl-job-admin/auth/login-by-code?code=" + code
|
||
+ '&redirectUri=' + redirectUri,
|
||
method: 'POST',
|
||
success: function (result) {
|
||
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;
|
||
}
|
||
// 设置cookie
|
||
document.cookie = "ACCESS_TOKEN=" + result.data.access_token + "; max-age=" + (result.data.expires_in - 20) + "; path=/xxl-job-admin";
|
||
document.cookie = "REFRESH_TOKEN=" + result.data.refresh_token + "; max-age=43000; path=/xxl-job-admin";
|
||
// 跳转回首页
|
||
window.location.href = '/xxl-job-admin';
|
||
}
|
||
})
|
||
}
|
||
}
|
||
// 情况三:已登录
|
||
else {
|
||
window.location.href = '/xxl-job-admin';
|
||
}
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|