diff --git a/src/api/login.ts b/src/api/login.ts index 6a5d441..e6abdb3 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -1,15 +1,15 @@ import { storeAuthTokens } from "@/constants/token"; import type { OAuthTokenResponse } from "@/constants/token"; -import { request, requestRaw } from "../utils/request"; +import { getRequestContext, request, requestRaw } from "../utils/request"; // 获取oauth token export interface OauthTokenRequest { grant_type?: string; - openIdCode?: string[]; + idToken?: string[]; scope?: string; mobile?: string; code?: string; - clientConfigld?: string; + clientConfigId?: string; [property: string]: any; } @@ -34,7 +34,11 @@ export function buildFormUrlEncodedParams( export async function oauthToken( data: OauthTokenRequest, ): Promise { - const params = buildFormUrlEncodedParams(data as Record); + const params = buildFormUrlEncodedParams({ + ...data, + clientId: data.clientId ?? getRequestContext().clientId ?? "6", + clientConfigId: data.clientConfigId ?? getRequestContext().clientId ?? "6", + } as Record); const res = await requestRaw( { @@ -66,7 +70,12 @@ export function sendCode(mobile: string) { url: `/admin/platformUser/sendMobileCode/${encoded}`, method: "get", }, - { skipAuth: true }, + { + skipAuth: true, + headers: { + clientConfigId: getRequestContext().clientId ?? "", + }, + }, ); } diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 61b7352..0c45b4e 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -253,7 +253,6 @@ async function handlePhoneLogin() { mobile: `${selectedCountry.value.dialCode}${phoneDigits}`, code: codeValue, grant_type: "mobile", - clientConfigld: '6', }); emitter.emit(NOTICE_EVENT_LOGIN_SUCCESS); await navigateAfterLogin(); @@ -332,7 +331,7 @@ onMounted(() => { const idToken = response.credential; if (idToken) { - oauthToken({ openIdCode: [idToken], grant_type: 'google', clientConfigld: '6' }) + oauthToken({ idToken: [idToken], grant_type: 'google', scope: 'server' }) .then(() => { emitter.emit(NOTICE_EVENT_LOGIN_SUCCESS); return navigateAfterLogin()