@sbc-connect/nuxt-auth 0.16.3 → 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 CHANGED
@@ -1,5 +1,17 @@
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
+
9
+ ## 0.16.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [#192](https://github.com/bcgov/connect-nuxt/pull/192) [`7a8ed9f`](https://github.com/bcgov/connect-nuxt/commit/7a8ed9f6ab50bafb165d5fe0dc90477ec7917458) Thanks [@kialj876](https://github.com/kialj876)! - Login description can be set by the preset override
14
+
3
15
  ## 0.16.3
4
16
 
5
17
  ### Patch Changes
@@ -5,6 +5,7 @@ export interface ConnectLoginConfig {
5
5
  idps: IdpList
6
6
  skipAccountRedirect: boolean
7
7
  idpEnforcement: boolean
8
+ description?: string | null
8
9
  alert?: {
9
10
  title?: string
10
11
  message?: string
@@ -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
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import loginImage from '#auth/public/img/BCReg_Generic_Login_image.jpg'
3
3
 
4
- const { t } = useI18n()
4
+ const { t, te } = useI18n()
5
5
  const { login } = useConnectAuth()
6
6
  const ac = useAppConfig().connect.login
7
7
 
@@ -18,6 +18,21 @@ definePageMeta({
18
18
 
19
19
  const isSessionExpired = sessionStorage.getItem(ConnectAuthStorageKey.CONNECT_SESSION_EXPIRED)
20
20
 
21
+ // app config (or preset) description overrides the default text
22
+ // - either an i18n key or a literal string
23
+ // - undefined (not specified) uses the default text
24
+ // - empty string or null hides the description
25
+ const description = computed(() => {
26
+ const override = ac.description
27
+ if (override === undefined) {
28
+ return t('connect.page.login.description')
29
+ }
30
+ if (!override) {
31
+ return ''
32
+ }
33
+ return te(override) ? t(override) : override
34
+ })
35
+
21
36
  const loginOptions = computed(() => {
22
37
  const loginOptionsMap: Record<
23
38
  ConnectValidIdpOption,
@@ -64,8 +79,12 @@ const loginOptions = computed(() => {
64
79
  <h1>
65
80
  {{ $t('connect.page.login.h1') }}
66
81
  </h1>
67
- <p class="max-w-[40rem] text-center">
68
- {{ $t('connect.page.login.description') }}
82
+ <p
83
+ v-if="description"
84
+ class="max-w-[40rem] text-center"
85
+ data-testid="login-description"
86
+ >
87
+ {{ description }}
69
88
  </p>
70
89
  <UAlert
71
90
  v-if="isSessionExpired"
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.3",
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",