diff --git a/nginx.conf b/nginx.conf index b63362a..ce8d76f 100644 --- a/nginx.conf +++ b/nginx.conf @@ -7,6 +7,10 @@ server { proxy_pass http://data-backend:8000; } + location /oauth2/v1/ { + proxy_pass http://auth-backend:8000; + } + location /api/v1/me { proxy_pass http://auth-backend:8000; } diff --git a/src/App.vue b/src/App.vue index f81cc74..445070a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -8,7 +8,6 @@ import { defineComponent } from 'vue'; import { ElConfigProvider } from 'element-plus'; import zhCn from 'element-plus/dist/locale/zh-cn.mjs'; -import { applicationOperator, userOperator } from './operators'; export default defineComponent({ components: { @@ -18,14 +17,6 @@ export default defineComponent({ return { locale: zhCn }; - }, - async mounted() { - const { data: user } = await userOperator.getMe(); - this.$store.dispatch('setUser', user); - const { data: applications } = await applicationOperator.getAll({ - user_id: user.id - }); - this.$store.dispatch('setApplications', applications); } }); diff --git a/src/components/midjourney/PresetPanel.vue b/src/components/midjourney/PresetPanel.vue index 415936d..af3eeef 100644 --- a/src/components/midjourney/PresetPanel.vue +++ b/src/components/midjourney/PresetPanel.vue @@ -64,7 +64,6 @@ export default defineComponent({ preset: { handler(val) { this.$emit('update:modelValue', val); - console.debug('preset changed', val); this.$store.dispatch('setMidjourney', { preset: val }); diff --git a/src/operators/auth/models.ts b/src/operators/auth/models.ts index 8fc7d02..de11953 100644 --- a/src/operators/auth/models.ts +++ b/src/operators/auth/models.ts @@ -4,3 +4,13 @@ export interface IToken { } export interface ITokenResponse extends IToken {} + +export interface IOAuthTokenRequest { + code: string; +} + +export interface IOAuthTokenResponse { + access_token: string; + expires_in: number; + refresh_token: string; +} diff --git a/src/operators/auth/operator.ts b/src/operators/auth/operator.ts index deb25c0..a13726e 100644 --- a/src/operators/auth/operator.ts +++ b/src/operators/auth/operator.ts @@ -1,6 +1,6 @@ import { AxiosResponse } from 'axios'; import { httpClient } from '../instance'; -import { ITokenResponse, IToken } from './models'; +import { ITokenResponse, IToken, IOAuthTokenRequest, IOAuthTokenResponse } from './models'; class AuthOperator { async refreshToken(payload: IToken): Promise> { @@ -8,4 +8,13 @@ class AuthOperator { } } +class OAuthOperator { + async token(payload: IOAuthTokenRequest): Promise> { + return httpClient.post('/token', payload, { + baseURL: '/oauth2/v1' + }); + } +} + export const authOperator = new AuthOperator(); +export const oauthOperator = new OAuthOperator(); diff --git a/src/pages/auth/Callback.vue b/src/pages/auth/Callback.vue index 1fc211f..fff0f4a 100644 --- a/src/pages/auth/Callback.vue +++ b/src/pages/auth/Callback.vue @@ -1,13 +1,14 @@