flat: tiket

This commit is contained in:
Apcallover
2024-04-15 18:01:50 +08:00
parent 4db1206fc9
commit b86ea914a3
4 changed files with 25 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
import website from '@/config/website';
import request from '@/router/axios';
export const loginByUsername = (username, password, type, key, code, loginType) =>
export const loginByUsername = (username, password, type, key, code, loginType, ticket) =>
request({
url: '/api/jobslink-auth/oauth/token',
method: 'post',
@@ -15,7 +15,8 @@ export const loginByUsername = (username, password, type, key, code, loginType)
password,
grant_type: (website.captchaMode ? 'captcha' : 'password'),
scope: 'all',
type
type,
ticket
}
});

View File

@@ -54,7 +54,7 @@ import { mapGetters } from "vuex";
import topLang from "@/page/index/top/top-lang";
// import { info } from "@/api/system/tenant";
import { getCaptcha } from "@/api/user";
if (/(\/login\b)(\?.*)(\&.*)/ig.test(location.href)) {
if (/(\/login\?)(.*)/ig.test(location.href)) {
const obj = {}
const query = location.href.split('?')[1].replace(/\?/, '').split('&')
query.forEach((item) => { const a = item.split('='); obj[a[0]] = a[1]})
@@ -100,6 +100,7 @@ export default {
passwordType: "password",
proLoading: false,
loading: null,
ticket: ''
};
},
watch: {
@@ -107,12 +108,12 @@ export default {
},
created () {
// this.getTenant();
const { username, password } = JSON.parse(window.sessionStorage.getItem('query_session') || "{}")
const { ticket } = JSON.parse(window.sessionStorage.getItem('query_session') || "{}")
window.sessionStorage.removeItem('query_session')
if(username && password) {
console.log(ticket)
if(ticket) {
this.proLoading = true
this.loginForm.username = username
this.loginForm.password = password
this.ticket = ticket
this.handleLogin()
} else {
console.log('刷新1')
@@ -143,7 +144,13 @@ export default {
},
handleLogin () {
if(this.proLoading) {
this.ByUsernameCallback()
let params = {
...this.loginForm,
username: "admin",
password: "admin",
ticket: this.ticket
}
this.ByUsernameCallback(params)
return
}
this.$refs.loginForm.validate(valid => {
@@ -152,13 +159,17 @@ export default {
}
});
},
ByUsernameCallback() {
ByUsernameCallback(params) {
const loading = this.$loading({
lock: true,
text: '登录中,请稍后。。。',
spinner: "el-icon-loading"
});
this.$store.dispatch("LoginByUsername", this.loginForm).then(() => {
let obj = this.loginForm
if(params) {
obj = params
}
this.$store.dispatch("LoginByUsername", obj).then(() => {
this.$store.dispatch('jlHelpShow', false)
this.$router.push({ path: this.tagWel.value });
loading.close();

View File

@@ -65,7 +65,8 @@ const user = {
userInfo.type,
userInfo.key,
userInfo.code,
userInfo.loginType
userInfo.loginType,
userInfo.ticket
)
.then((res) => {
const data = res.data;