bt-core-app 1.3.0 → 1.3.2
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 +2064 -2061
- package/package.json +1 -1
- package/src/composables/auth.ts +13 -4
- package/test/auth.test.ts +10 -3
package/package.json
CHANGED
package/src/composables/auth.ts
CHANGED
|
@@ -233,7 +233,8 @@ export function createAuth(options: CreateAuthOptions): BTAuth {
|
|
|
233
233
|
|
|
234
234
|
function getAuthorizeUrl(redirectPath?: string) {
|
|
235
235
|
options.getAuthorizeUrl ??= (redirectPath?: string, state?: string) => {
|
|
236
|
-
|
|
236
|
+
const path = appendUrl(useAuthUrl(), `authorize?response_type=code&client_id=${options.oauthClientID}&redirect_uri=${window.location.origin}/authentication&state=${state}`)
|
|
237
|
+
return redirectPath ? `${path}&redirect_path=${redirectPath}` : path
|
|
237
238
|
}
|
|
238
239
|
|
|
239
240
|
if (options.getAuthorizeUrl != null)
|
|
@@ -316,7 +317,7 @@ export function createAuth(options: CreateAuthOptions): BTAuth {
|
|
|
316
317
|
|
|
317
318
|
let mCode = code ?? route.query?.code as string
|
|
318
319
|
let mState = state ?? route.query?.state as string
|
|
319
|
-
let
|
|
320
|
+
let mRedirectPath = redirect_path ?? route.query?.redirect_path as string
|
|
320
321
|
let mGrantType = options.oauthGrantType ?? 'authorization_token'
|
|
321
322
|
let mClientID = options.oauthClientID ?? ''
|
|
322
323
|
|
|
@@ -333,7 +334,7 @@ export function createAuth(options: CreateAuthOptions): BTAuth {
|
|
|
333
334
|
return appendUrl(useAuthUrl(), 'token')
|
|
334
335
|
}
|
|
335
336
|
|
|
336
|
-
url = options.getTokenUrl(mCode,
|
|
337
|
+
url = options.getTokenUrl(mCode, `${window.location.origin}/authentication`, mGrantType, mClientID)
|
|
337
338
|
|
|
338
339
|
const formData: any = {}
|
|
339
340
|
formData['grant_type'] = mGrantType
|
|
@@ -351,9 +352,17 @@ export function createAuth(options: CreateAuthOptions): BTAuth {
|
|
|
351
352
|
const data = await res.json()
|
|
352
353
|
|
|
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
|
+
}
|
|
354
363
|
}
|
|
355
364
|
|
|
356
|
-
return await getToken(
|
|
365
|
+
return await options.getToken()
|
|
357
366
|
}
|
|
358
367
|
|
|
359
368
|
/**if not demoing, then will decrypt the jwtToken and attempt to set credentials */
|
package/test/auth.test.ts
CHANGED
|
@@ -42,8 +42,7 @@ afterEach(() => server.resetHandlers())
|
|
|
42
42
|
describe('default auth', () => {
|
|
43
43
|
const auth = createAuth({
|
|
44
44
|
defaultTimeZone: 'Aus',
|
|
45
|
-
getAuthItem: () => { return {}}
|
|
46
|
-
getAuthQuery: () => ''
|
|
45
|
+
getAuthItem: () => { return {}}
|
|
47
46
|
})
|
|
48
47
|
|
|
49
48
|
test('creates successfully', () => {
|
|
@@ -64,4 +63,12 @@ describe('default auth', () => {
|
|
|
64
63
|
test('login', () => {
|
|
65
64
|
auth.login()
|
|
66
65
|
})
|
|
67
|
-
})
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// describe('auth', () => {
|
|
69
|
+
// const auth = createAuth({})
|
|
70
|
+
|
|
71
|
+
// test('get auth url', () => {
|
|
72
|
+
// expect(auth.getAuthorizeUrl('redirect')).toEqual('a')
|
|
73
|
+
// })
|
|
74
|
+
// })
|