bt-core-app 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bt-core-app.js +461 -464
- package/package.json +1 -1
- package/src/composables/auth.ts +17 -21
package/package.json
CHANGED
package/src/composables/auth.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { type BTDemo } from '../composables/demo'
|
|
|
5
5
|
import { useRouter } from 'vue-router'
|
|
6
6
|
import { toValue } from 'vue'
|
|
7
7
|
import { useAuthUrl } from './urls'
|
|
8
|
+
import { useApi } from './api'
|
|
8
9
|
|
|
9
10
|
export interface AuthItem {
|
|
10
11
|
children?: AuthItem[]
|
|
@@ -313,11 +314,8 @@ export function createAuth(options: CreateAuthOptions): BTAuth {
|
|
|
313
314
|
/**defaults to find parameters from route query */
|
|
314
315
|
async function getToken(code?: string, state?: string) {
|
|
315
316
|
options.getToken ??= async () => {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
let mCode = code // ?? route.query?.code as string
|
|
319
|
-
let mState = state //?? route.query?.state as string
|
|
320
|
-
// let mRedirectPath = redirect_path // ?? route.query?.redirect_path as string
|
|
317
|
+
let mCode = code
|
|
318
|
+
let mState = state
|
|
321
319
|
let mGrantType = options.oauthGrantType ?? 'authorization_token'
|
|
322
320
|
let mClientID = options.oauthClientID ?? ''
|
|
323
321
|
|
|
@@ -342,24 +340,22 @@ export function createAuth(options: CreateAuthOptions): BTAuth {
|
|
|
342
340
|
formData['redirect_uri'] = `${window.location.origin}/authentication`
|
|
343
341
|
formData['client_id'] = mClientID
|
|
344
342
|
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
body: JSON.stringify(formData)
|
|
343
|
+
const api = useApi()
|
|
344
|
+
const res = await api.post<any>({
|
|
345
|
+
additionalUrl: url,
|
|
346
|
+
data: formData
|
|
350
347
|
})
|
|
348
|
+
|
|
349
|
+
// const res = await fetch(url, {
|
|
350
|
+
// method: 'POST',
|
|
351
|
+
// mode: 'cors',
|
|
352
|
+
// cache: 'no-cache',
|
|
353
|
+
// body: JSON.stringify(formData)
|
|
354
|
+
// })
|
|
355
|
+
|
|
356
|
+
// const data = await res.json()
|
|
351
357
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
setAuth(data.value?.access_token)
|
|
355
|
-
|
|
356
|
-
// if (mRedirectPath) {
|
|
357
|
-
// window.location.href = mRedirectPath
|
|
358
|
-
// }
|
|
359
|
-
// else {
|
|
360
|
-
// const router = useRouter()
|
|
361
|
-
// router.push({ name: 'home' })
|
|
362
|
-
// }
|
|
358
|
+
setAuth(res.access_token)
|
|
363
359
|
}
|
|
364
360
|
|
|
365
361
|
return await options.getToken(code, state)
|