@sbc-connect/nuxt-auth 0.16.4 → 0.16.5
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/CHANGELOG.md +6 -0
- package/app/middleware/connect-auth.ts +14 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @sbc-connect/nuxt-auth
|
|
2
2
|
|
|
3
|
+
## 0.16.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#194](https://github.com/bcgov/connect-nuxt/pull/194) [`a765c6e`](https://github.com/bcgov/connect-nuxt/commit/a765c6e9a87608e7a2c6e07abffd410a1e7e30c7) Thanks [@kialj876](https://github.com/kialj876)! - 34765 Auth - allow pre selecting login from redirect
|
|
8
|
+
|
|
3
9
|
## 0.16.4
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default defineNuxtRouteMiddleware(async (to) => {
|
|
2
|
-
const { isAuthenticated } = useConnectAuth()
|
|
2
|
+
const { isAuthenticated, login } = useConnectAuth()
|
|
3
3
|
const rtc = useRuntimeConfig().public
|
|
4
4
|
const localePath = useLocalePath()
|
|
5
5
|
const service = useConnectAuthService()
|
|
@@ -8,6 +8,19 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
|
|
8
8
|
const isLoginPage = to.meta.connectLogin === true
|
|
9
9
|
const isTosPage = to.meta.connectTosPage === true
|
|
10
10
|
|
|
11
|
+
// a valid idp query param (e.g. ?idp=bcsc) triggers that login instead of showing the login options
|
|
12
|
+
// - the idp must be in the app's allowed idps list
|
|
13
|
+
if (!isAuthenticated.value && !rtc.playwright) {
|
|
14
|
+
const idp = String(to.query.idp ?? '')
|
|
15
|
+
if ((useAppConfig().connect.login.idps as string[]).includes(idp)) {
|
|
16
|
+
// remove the idp param from the Keycloak redirect URI so a cancelled login
|
|
17
|
+
// returns to the login options instead of re-triggering
|
|
18
|
+
const redirectUrl = new URL(`${rtc.baseUrl}${to.fullPath.slice(1)}`)
|
|
19
|
+
redirectUrl.searchParams.delete('idp')
|
|
20
|
+
return login(idp as ConnectIdpHint, redirectUrl.href)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
if (!isAuthenticated.value && !isLoginPage && !rtc.playwright) {
|
|
12
25
|
const defaultReturn = `${rtc.baseUrl}${to.fullPath.slice(1)}`
|
|
13
26
|
const returnUrl = (to.query.return && String(to.query.return)) || defaultReturn
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sbc-connect/nuxt-auth",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.5",
|
|
5
5
|
"repository": "github:bcgov/connect-nuxt",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"nuxt": "4.4.8",
|
|
12
12
|
"typescript": "6.0.3",
|
|
13
13
|
"vue-tsc": "3.3.1",
|
|
14
|
-
"@sbc-connect/eslint-config": "0.0.8",
|
|
15
14
|
"@sbc-connect/playwright-config": "0.2.0",
|
|
16
|
-
"@sbc-connect/vitest-config": "0.2.0"
|
|
15
|
+
"@sbc-connect/vitest-config": "0.2.0",
|
|
16
|
+
"@sbc-connect/eslint-config": "0.0.8"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@pinia/colada": "1.3.0",
|