update callback

This commit is contained in:
AceDataCloud committed 2022-02-05 14:12:12 +08:00
1 parent 09f7a36edd
commit a63c85796b
9 files changed
+99 -44

No files matched your search

-14
View File
@@ -1,14 +0,0 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: zhishuyun-auth-frontend
name: zhishuyun-auth-frontend
namespace: zhishuyun
spec:
ports:
- name: '8083'
port: 8083
targetPort: 80
selector:
app: zhishuyun-auth-frontend
@@ -2,23 +2,23 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: zhishuyun-auth-frontend
name: zhishuyun-auth-frontend
namespace: zhishuyun
app: zhishuyun-academy-frontend
name: zhishuyun-academy-frontend
namespace: zhishuyun-test
spec:
replicas: 2
replicas: 1
revisionHistoryLimit: 5
selector:
matchLabels:
app: zhishuyun-auth-frontend
app: zhishuyun-academy-frontend
template:
metadata:
labels:
app: zhishuyun-auth-frontend
app: zhishuyun-academy-frontend
spec:
containers:
- image: ghcr.io/zhishuyun/zhishuyun-auth-frontend:${TAG}
name: zhishuyun-auth-frontend
- image: ghcr.io/zhishuyun/zhishuyun-academy-frontend:${TAG}
name: zhishuyun-academy-frontend
ports:
- containerPort: 80
resources:
@@ -1,8 +1,8 @@
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: ingress-zhishuyun-auth-frontend
namespace: zhishuyun
name: ingress-zhishuyun-academy-frontend
namespace: zhishuyun-test
annotations:
kubernetes.io/ingress.class: 'nginx'
nginx.ingress.kubernetes.io/ssl-redirect: 'true'
@@ -10,13 +10,13 @@ metadata:
spec:
tls:
- hosts:
- auth.zhishuyun.com
secretName: tls-auth-zhishuyun-com
- academy.test.zhishuyun.com
secretName: tls-wildcard-test-zhishuyun-com
rules:
- host: auth.zhishuyun.com
- host: academy.test.zhishuyun.com
http:
paths:
- backend:
serviceName: zhishuyun-auth-frontend
serviceName: zhishuyun-academy-frontend
servicePort: 8083
path: /
+14
View File
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: zhishuyun-academy-frontend
name: zhishuyun-academy-frontend
namespace: zhishuyun-test
spec:
ports:
- name: '8083'
port: 8083
targetPort: 80
selector:
app: zhishuyun-academy-frontend
+1
View File
@@ -13,6 +13,7 @@
"element-plus": "^1.3.0-beta.10",
"humps": "^2.0.1",
"qrcode.vue": "3.3.0",
"typescript-cookie": "^1.0.3",
"vue": "^3.2.6",
"vue-i18n": "^9.1.7",
"vue-router": "^4.0.11",
+49
View File
@@ -0,0 +1,49 @@
<template>
<div></div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { getCookie } from 'typescript-cookie';
interface IData {
accessToken: string | undefined;
refreshToken: string | undefined;
redirect: string | undefined;
}
export default defineComponent({
name: 'Login',
data(): IData {
return {
accessToken: undefined,
refreshToken: undefined,
redirect: this.$route.query.redirect?.toString()
};
},
async mounted() {
this.accessToken = getCookie('ACCESS_TOKEN');
this.refreshToken = getCookie('REFRESH_TOKEN');
if (this.accessToken && this.refreshToken) {
await this.$store.dispatch('setAccessToken', this.accessToken);
await this.$store.dispatch('setRefreshToken', this.refreshToken);
if (this.redirect) {
this.$router.push(this.redirect);
}
} else {
const currentUrl = window.location.href;
const targetUrl = `https://auth.zhishuyun.com?redirect=${currentUrl}`;
window.location.href = targetUrl;
}
},
methods: {}
});
</script>
<style lang="scss" scoped>
.panel {
.title {
text-align: center;
font-size: 22px;
}
}
</style>
+7 -15
View File
@@ -5,8 +5,6 @@
import { defineComponent } from 'vue';
interface IData {
accessToken: string | undefined;
refreshToken: string | undefined;
redirect: string | undefined;
}
@@ -14,23 +12,17 @@ export default defineComponent({
name: 'Login',
data(): IData {
return {
accessToken: this.$route.query['access-token']?.toString(),
refreshToken: this.$route.query['refresh-token']?.toString(),
redirect: this.$route.query.redirect?.toString()
};
},
async mounted() {
if (this.accessToken && this.refreshToken) {
await this.$store.dispatch('setAccessToken', this.accessToken);
await this.$store.dispatch('setRefreshToken', this.refreshToken);
if (this.redirect) {
this.$router.push(this.redirect);
}
} else {
const currentUrl = window.location.href;
const targetUrl = `https://auth.zhishuyun.com?redirect=${currentUrl}`;
window.location.href = targetUrl;
}
const host = window.location.host;
const subDomain = host.substring(host.indexOf('.') + 1);
// callback url used to init access token and then redirect back of `redirect`
const callbackUrl = `https://${host}/auth/callback?redirect=${this.redirect}`;
// redirect to auth service to get access token then redirect back
const targetUrl = `https://auth.${subDomain}?redirect=${callbackUrl}`;
window.location.href = targetUrl;
},
methods: {}
});
+9 -1
View File
@@ -10,11 +10,19 @@ export default {
children: [
{
path: 'login',
name: 'login',
name: 'auth-login',
meta: {
title: t('common.nav.article')
},
component: () => import('@/pages/auth/Login.vue')
},
{
path: 'callback',
name: 'auth-callback',
meta: {
title: t('common.nav.article')
},
component: () => import('@/pages/auth/Callback.vue')
}
]
};
+5
View File
@@ -2258,6 +2258,11 @@ type-fest@^0.20.2:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
typescript-cookie@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/typescript-cookie/-/typescript-cookie-1.0.3.tgz#fa036aac4937ee528258035b7495a7813a7656d5"
integrity sha512-eGu8HYw2oI+NXV7JJ1QDFi02EWYTl8zENevq5kSI3JcAdCxtUvjW6Nj5Mjrej83/oK8O/5OyRDuivhSFU49GcA==
typescript@^4.3.2:
version "4.5.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"