2020 :ldap="loginCategory.ldap"
2121 @status-change="qrStatusChange"
2222 />
23- <Oidc v-if="loginCategory.oidc" @switch-category="switcherCategory" />
24- <Oauth2 v-if="loginCategory.oauth2" ref="oauth2Handler" @switch-category="switcherCategory" /> -->
23+ <Oidc v-if="loginCategory.oidc" @switch-category="switcherCategory" /> -->
24+ <Oauth2 v-if =" loginCategory.oauth2" ref =" oauth2Handler" @switch-category =" switcherCategory" />
2525 <Cas v-if =" loginCategory.cas" @switch-category =" switcherCategory" />
2626 <!-- <Saml2 v-if="loginCategory.saml2" ref="saml2Handler" @switch-category="switcherCategory" /> -->
2727 </div >
@@ -38,13 +38,14 @@ import Oidc from './Oidc.vue'
3838import Oauth2 from './Oauth2.vue'
3939import Saml2 from './Saml2.vue' */
4040import Cas from ' ./Cas.vue'
41+ import Oauth2 from ' ./Oauth2.vue'
4142// import QrTab from './QrTab.vue'
4243import { request } from ' @/utils/request'
4344import { useCache } from ' @/utils/useCache'
4445
4546import router from ' @/router'
4647import { useUserStore } from ' @/stores/user.ts'
47- import { getQueryString , isPlatformClient } from ' @/utils/utils'
48+ import { getQueryString , getUrlParams , isPlatformClient } from ' @/utils/utils'
4849import { loadClient , type LoginCategory } from ' ./PlatformClient'
4950// import MfaStep from './MfaStep.vue'
5051// import { logoutHandler } from '@/utils/logout'
@@ -150,7 +151,10 @@ const switcherCategory = (param: Categoryparam) => {
150151 }
151152 const nextPage = curOrigin + pathname + proxy + curLocation
152153 if (category === ' oauth2' ) {
153- oauth2Handler ?.value ?.toLoginPage ()
154+ request .get (' /system/authentication/login/4' ).then ((res : any ) => {
155+ window .location .href = res
156+ window .open (res , ' _self' )
157+ })
154158 return
155159 }
156160 if (category === ' saml2' ) {
@@ -176,9 +180,12 @@ const getCurLocation = () => {
176180}
177181
178182const casLogin = () => {
183+ const urlParams = getUrlParams ()
179184 const ticket = getQueryString (' ticket' )
185+ /* request
186+ .get('/system/authentication/sso/cas?ticket=' + ticket) */
180187 request
181- .get (' /system/authentication/sso/cas?ticket= ' + ticket )
188+ .post (' /system/authentication/sso/1 ' , urlParams )
182189 .then ((res : any ) => {
183190 const token = res .access_token
184191 if (token && isPlatformClient ()) {
@@ -207,6 +214,39 @@ const casLogin = () => {
207214 }, 1500 )
208215 })
209216}
217+ const oauth2Login = () => {
218+ const urlParams = getUrlParams ()
219+ request
220+ .post (' /system/authentication/sso/4' , urlParams )
221+ .then ((res : any ) => {
222+ const token = res .access_token
223+ const id_token = res .id_token
224+ if (token && isPlatformClient ()) {
225+ wsCache .set (' de-platform-client' , true )
226+ }
227+ userStore .setToken (token )
228+ userStore .setExp (res .exp )
229+ userStore .setTime (Date .now ())
230+ userStore .setPlatformInfo ({
231+ flag: ' oauth2' ,
232+ data: id_token ,
233+ origin: 4 ,
234+ })
235+ const queryRedirectPath = getCurLocation ()
236+ router .push ({ path: queryRedirectPath })
237+ })
238+ .catch ((e : any ) => {
239+ userStore .setToken (' ' )
240+ setTimeout (() => {
241+ // logoutHandler(true, true)
242+ platformLoginMsg .value = e ?.message || e
243+ setTimeout (() => {
244+ window .location .href =
245+ window .location .origin + window .location .pathname + window .location .hash
246+ }, 2000 )
247+ }, 1500 )
248+ })
249+ }
210250/* const platformLogin = (origin: number) => {
211251 const url = '/system/authentication/sso/cas'
212252 request
@@ -384,6 +424,8 @@ onMounted(() => {
384424 if (state ?.includes (' cas' ) && getQueryString (' ticket' )) {
385425 // platformLogin(1)
386426 casLogin ()
427+ } else if (state ?.includes (' oauth2' )) {
428+ oauth2Login ()
387429 } else {
388430 updateLoading (false )
389431 }
0 commit comments