| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2022-02-23 15:04:45 -09:00
										 |  |  |   <v-container | 
					
						
							|  |  |  |     fluid | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     class="d-flex justify-center align-center flex-column fill-height" | 
					
						
							| 
									
										
										
										
											2022-02-23 15:04:45 -09:00
										 |  |  |     :class="{ | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       'bg-off-white': !$vuetify.theme.current.dark && !isDark, | 
					
						
							| 
									
										
										
										
											2022-02-23 15:04:45 -09:00
										 |  |  |     }" | 
					
						
							|  |  |  |   > | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <v-alert | 
					
						
							|  |  |  |       v-if="isFirstLogin" | 
					
						
							|  |  |  |       class="my-4" | 
					
						
							|  |  |  |       type="info" | 
					
						
							|  |  |  |       :icon="$globals.icons.information" | 
					
						
							|  |  |  |       :style="{ flex: 'none' }" | 
					
						
							|  |  |  |     > | 
					
						
							| 
									
										
										
										
											2023-11-15 09:24:24 -06:00
										 |  |  |       <div> | 
					
						
							|  |  |  |         <p class="mb-3"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           {{ $t('user.it-looks-like-this-is-your-first-time-logging-in') }} | 
					
						
							|  |  |  |         </p> | 
					
						
							|  |  |  |         <p class="mb-1"> | 
					
						
							| 
									
										
										
										
											2025-08-11 18:27:10 +02:00
										 |  |  |           <strong>{{ $t('user.username') }}: </strong>changeme@example.com | 
					
						
							|  |  |  |           <AppButtonCopy | 
					
						
							|  |  |  |             copy-text="changeme@example.com" | 
					
						
							|  |  |  |             color="info" | 
					
						
							|  |  |  |             btn-class="h-auto" | 
					
						
							|  |  |  |           /> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         </p> | 
					
						
							|  |  |  |         <p class="mb-3"> | 
					
						
							| 
									
										
										
										
											2025-08-11 18:27:10 +02:00
										 |  |  |           <strong>{{ $t('user.password') }}: </strong>MyPassword | 
					
						
							|  |  |  |           <AppButtonCopy | 
					
						
							|  |  |  |             copy-text="MyPassword" | 
					
						
							|  |  |  |             color="info" | 
					
						
							|  |  |  |             btn-class="h-auto" | 
					
						
							|  |  |  |           /> | 
					
						
							| 
									
										
										
										
											2023-11-15 09:24:24 -06:00
										 |  |  |         </p> | 
					
						
							|  |  |  |         <p> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           {{ $t('user.dont-want-to-see-this-anymore-be-sure-to-change-your-email') }} | 
					
						
							| 
									
										
										
										
											2023-11-15 09:24:24 -06:00
										 |  |  |         </p> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     </v-alert> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <v-card | 
					
						
							|  |  |  |       tag="section" | 
					
						
							|  |  |  |       class="d-flex flex-column align-center w-100" | 
					
						
							|  |  |  |       max-width="600" | 
					
						
							|  |  |  |     > | 
					
						
							|  |  |  |       <v-toolbar | 
					
						
							|  |  |  |         color="primary" | 
					
						
							|  |  |  |         class="d-flex justify-center mb-4" | 
					
						
							|  |  |  |         dark | 
					
						
							|  |  |  |       > | 
					
						
							|  |  |  |         <v-toolbar-title class="text-h4 text-center"> | 
					
						
							|  |  |  |           Mealie | 
					
						
							|  |  |  |         </v-toolbar-title> | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |       </v-toolbar> | 
					
						
							| 
									
										
										
										
											2025-09-09 19:21:58 +02:00
										 |  |  |       <AppLogo :size="100" /> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       <v-card-title class="text-h5 justify-center pb-3"> | 
					
						
							|  |  |  |         {{ $t('user.sign-in') }} | 
					
						
							|  |  |  |       </v-card-title> | 
					
						
							|  |  |  |       <v-card-text class="w-100"> | 
					
						
							| 
									
										
										
										
											2022-03-22 20:41:54 -08:00
										 |  |  |         <v-form @submit.prevent="authenticate"> | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |           <v-text-field | 
					
						
							| 
									
										
										
										
											2025-05-27 15:49:06 -04:00
										 |  |  |             v-if="allowPasswordLogin" | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |             v-model="form.email" | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |             :prepend-inner-icon="$globals.icons.email" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             variant="solo-filled" | 
					
						
							|  |  |  |             flat | 
					
						
							|  |  |  |             width="100%" | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |             autofocus | 
					
						
							| 
									
										
										
										
											2025-01-05 16:28:19 -05:00
										 |  |  |             autocomplete="username" | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |             name="login" | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |             :label="$t('user.email-or-username')" | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |             type="text" | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <v-text-field | 
					
						
							| 
									
										
										
										
											2025-05-27 15:49:06 -04:00
										 |  |  |             v-if="allowPasswordLogin" | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |             id="password" | 
					
						
							|  |  |  |             v-model="form.password" | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |             :prepend-inner-icon="$globals.icons.lock" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             :append-inner-icon="passwordIcon" | 
					
						
							|  |  |  |             variant="solo-filled" | 
					
						
							|  |  |  |             flat | 
					
						
							| 
									
										
										
										
											2025-01-05 16:28:19 -05:00
										 |  |  |             autocomplete="current-password" | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |             name="password" | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |             :label="$t('user.password')" | 
					
						
							| 
									
										
										
										
											2022-03-22 20:41:54 -08:00
										 |  |  |             :type="inputType" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             @click:append-inner="togglePasswordShow" | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <v-checkbox | 
					
						
							|  |  |  |             v-if="allowPasswordLogin" | 
					
						
							|  |  |  |             v-model="form.remember" | 
					
						
							|  |  |  |             class="ml-2 mt-n2" | 
					
						
							|  |  |  |             :label="$t('user.remember-me')" | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |           /> | 
					
						
							| 
									
										
										
										
											2025-05-27 15:49:06 -04:00
										 |  |  |           <v-card-actions v-if="allowPasswordLogin" class="justify-center pt-0"> | 
					
						
							| 
									
										
										
										
											2021-10-02 12:18:01 -08:00
										 |  |  |             <div class="max-button"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |               <v-btn | 
					
						
							|  |  |  |                 :loading="loggingIn" | 
					
						
							|  |  |  |                 :disabled="oidcLoggingIn" | 
					
						
							|  |  |  |                 variant="elevated" | 
					
						
							|  |  |  |                 color="primary" | 
					
						
							|  |  |  |                 type="submit" | 
					
						
							|  |  |  |                 size="large" | 
					
						
							|  |  |  |                 rounded | 
					
						
							|  |  |  |                 class="rounded-xl" | 
					
						
							|  |  |  |                 block | 
					
						
							|  |  |  |               > | 
					
						
							| 
									
										
										
										
											2021-10-02 12:18:01 -08:00
										 |  |  |                 {{ $t("user.login") }} | 
					
						
							|  |  |  |               </v-btn> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           </v-card-actions> | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <div | 
					
						
							| 
									
										
										
										
											2025-09-27 12:26:02 -05:00
										 |  |  |             v-if="appInfoLoaded && allowOidc && allowPasswordLogin" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             class="d-flex my-4 justify-center align-center" | 
					
						
							|  |  |  |             width="80%" | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |             <v-divider class="div-width" /> | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |             <span | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |               class="absolute px-2" | 
					
						
							|  |  |  |               :class="{ | 
					
						
							|  |  |  |                 'bg-white': !$vuetify.theme.current.dark && !isDark, | 
					
						
							|  |  |  |                 'bg-grey-darken-4': $vuetify.theme.current.dark || isDark, | 
					
						
							|  |  |  |               }" | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |             > | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |               {{ $t("user.or") }} | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |             </span> | 
					
						
							|  |  |  |           </div> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <v-card-actions | 
					
						
							| 
									
										
										
										
											2025-09-27 12:26:02 -05:00
										 |  |  |             v-if="appInfoLoaded && allowOidc" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |             class="justify-center" | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |             <div class="max-button"> | 
					
						
							|  |  |  |               <v-btn | 
					
						
							|  |  |  |                 :loading="oidcLoggingIn" | 
					
						
							|  |  |  |                 color="primary" | 
					
						
							|  |  |  |                 size="large" | 
					
						
							|  |  |  |                 variant="elevated" | 
					
						
							|  |  |  |                 rounded | 
					
						
							|  |  |  |                 class="rounded-xl" | 
					
						
							|  |  |  |                 block | 
					
						
							|  |  |  |                 @click="() => oidcAuthenticate()" | 
					
						
							|  |  |  |               > | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |                 {{ $t("user.login-oidc") }} {{ oidcProviderName }} | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |               </v-btn> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           </v-card-actions> | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |         </v-form> | 
					
						
							|  |  |  |       </v-card-text> | 
					
						
							| 
									
										
										
										
											2023-10-07 21:36:47 +02:00
										 |  |  |       <v-card-actions class="d-flex justify-center flex-column flex-sm-row"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         <v-btn | 
					
						
							|  |  |  |           v-if="allowSignup && allowPasswordLogin" | 
					
						
							|  |  |  |           variant="text" | 
					
						
							|  |  |  |           to="/register" | 
					
						
							|  |  |  |         > | 
					
						
							|  |  |  |           {{ $t("user.register") }} | 
					
						
							|  |  |  |         </v-btn> | 
					
						
							|  |  |  |         <v-btn | 
					
						
							|  |  |  |           v-else | 
					
						
							|  |  |  |           variant="text" | 
					
						
							|  |  |  |           disabled | 
					
						
							|  |  |  |         > | 
					
						
							|  |  |  |           {{ $t("user.invite-only") }} | 
					
						
							|  |  |  |         </v-btn> | 
					
						
							|  |  |  |         <v-btn | 
					
						
							|  |  |  |           v-if="allowPasswordLogin" | 
					
						
							|  |  |  |           class="mr-auto" | 
					
						
							|  |  |  |           variant="text" | 
					
						
							|  |  |  |           to="/forgot-password" | 
					
						
							|  |  |  |         > | 
					
						
							|  |  |  |           {{ $t("user.reset-password") }} | 
					
						
							|  |  |  |         </v-btn> | 
					
						
							| 
									
										
										
										
											2021-10-07 09:39:47 -08:00
										 |  |  |       </v-card-actions> | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-21 20:41:18 +02:00
										 |  |  |       <v-card-text class="d-flex justify-center flex-column flex-sm-row"> | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |         <div | 
					
						
							|  |  |  |           v-for="link in [ | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               text: $t('about.sponsor'), | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |               icon: $globals.icons.heart, | 
					
						
							|  |  |  |               href: 'https://github.com/sponsors/hay-kot', | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               text: $t('about.github'), | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |               icon: $globals.icons.github, | 
					
						
							| 
									
										
										
										
											2025-08-01 10:43:57 +02:00
										 |  |  |               href: 'https://github.com/mealie-recipes/mealie', | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               text: $t('about.docs'), | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |               icon: $globals.icons.folderOutline, | 
					
						
							|  |  |  |               href: 'https://docs.mealie.io/', | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |           ]" | 
					
						
							|  |  |  |           :key="link.text" | 
					
						
							| 
									
										
										
										
											2023-08-21 20:41:18 +02:00
										 |  |  |           class="text-center" | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |         > | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <v-btn | 
					
						
							|  |  |  |             variant="text" | 
					
						
							|  |  |  |             :href="link.href" | 
					
						
							|  |  |  |             target="_blank" | 
					
						
							|  |  |  |           > | 
					
						
							|  |  |  |             <v-icon start> | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  |               {{ link.icon }} | 
					
						
							|  |  |  |             </v-icon> | 
					
						
							|  |  |  |             {{ link.text }} | 
					
						
							|  |  |  |           </v-btn> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </v-card-text> | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |     </v-card> | 
					
						
							|  |  |  |   </v-container> | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | </template> | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2023-01-06 11:51:38 -08:00
										 |  |  | import { useDark, whenever } from "@vueuse/core"; | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  | import { useLoggedInState } from "~/composables/use-logged-in-state"; | 
					
						
							| 
									
										
										
										
											2022-03-15 17:34:53 -08:00
										 |  |  | import { useAppInfo } from "~/composables/api"; | 
					
						
							| 
									
										
										
										
											2022-05-06 11:18:06 -08:00
										 |  |  | import { usePasswordField } from "~/composables/use-passwords"; | 
					
						
							| 
									
										
										
										
											2021-11-20 14:30:38 -09:00
										 |  |  | import { alert } from "~/composables/use-toast"; | 
					
						
							| 
									
										
										
										
											2023-11-15 09:24:24 -06:00
										 |  |  | import { useAsyncKey } from "~/composables/use-utils"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { AppStartupInfo } from "~/lib/api/types/admin"; | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | export default defineNuxtComponent({ | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |   setup() { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     definePageMeta({ | 
					
						
							|  |  |  |       layout: "blank", | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2022-03-15 17:34:53 -08:00
										 |  |  |     const isDark = useDark(); | 
					
						
							| 
									
										
										
										
											2022-02-23 15:04:45 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-06 11:51:38 -08:00
										 |  |  |     const router = useRouter(); | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const i18n = useI18n(); | 
					
						
							|  |  |  |     const $auth = useMealieAuth(); | 
					
						
							|  |  |  |     const { $axios } = useNuxtApp(); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  |     const { loggedIn } = useLoggedInState(); | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const groupSlug = computed(() => $auth.user.value?.groupSlug); | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  |     const isDemo = ref(false); | 
					
						
							|  |  |  |     const isFirstLogin = ref(false); | 
					
						
							| 
									
										
										
										
											2023-01-06 11:51:38 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     useSeoMeta({ | 
					
						
							|  |  |  |       title: i18n.t("user.login"), | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |     const form = reactive({ | 
					
						
							| 
									
										
										
										
											2022-02-20 15:14:31 -09:00
										 |  |  |       email: "", | 
					
						
							|  |  |  |       password: "", | 
					
						
							| 
									
										
										
										
											2021-12-04 16:06:24 -09:00
										 |  |  |       remember: false, | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     useAsyncData(useAsyncKey(), async () => { | 
					
						
							| 
									
										
										
										
											2023-11-15 09:24:24 -06:00
										 |  |  |       const data = await $axios.get<AppStartupInfo>("/api/app/about/startup-info"); | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  |       isDemo.value = data.data.isDemo; | 
					
						
							| 
									
										
										
										
											2023-11-15 09:24:24 -06:00
										 |  |  |       isFirstLogin.value = data.data.isFirstLogin; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     whenever( | 
					
						
							|  |  |  |       () => loggedIn.value && groupSlug.value, | 
					
						
							|  |  |  |       () => { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         if (!isDemo.value && isFirstLogin.value && $auth.user.value?.admin) { | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  |           router.push("/admin/setup"); | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  |           router.push(`/g/${groupSlug.value || ""}`); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       { immediate: true }, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-11-15 09:24:24 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |     const loggingIn = ref(false); | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const oidcLoggingIn = ref(false); | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-15 17:34:53 -08:00
										 |  |  |     const appInfo = useAppInfo(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-22 20:41:54 -08:00
										 |  |  |     const { passwordIcon, inputType, togglePasswordShow } = usePasswordField(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-27 12:26:02 -05:00
										 |  |  |     const appInfoLoaded = computed(() => appInfo.value !== null); | 
					
						
							| 
									
										
										
										
											2022-03-15 17:34:53 -08:00
										 |  |  |     const allowSignup = computed(() => appInfo.value?.allowSignup || false); | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |     const allowOidc = computed(() => appInfo.value?.enableOidc || false); | 
					
						
							|  |  |  |     const oidcRedirect = computed(() => appInfo.value?.oidcRedirect || false); | 
					
						
							| 
									
										
										
										
											2025-05-27 15:49:06 -04:00
										 |  |  |     const oidcProviderName = computed(() => appInfo.value?.oidcProviderName || "OAuth"); | 
					
						
							|  |  |  |     const allowPasswordLogin = computed(() => appInfo.value?.allowPasswordLogin ?? true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |     whenever( | 
					
						
							| 
									
										
										
										
											2025-09-27 12:26:02 -05:00
										 |  |  |       () => appInfoLoaded.value && allowOidc.value && oidcRedirect.value && !isCallback() && !isDirectLogin() /* && !$auth.check().valid */, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       () => oidcAuthenticate(), | 
					
						
							|  |  |  |       { immediate: true }, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-05 16:12:11 -05:00
										 |  |  |     onBeforeMount(async () => { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       if (isCallback()) { | 
					
						
							|  |  |  |         await oidcAuthenticate(true); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2024-10-05 16:12:11 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |     function isCallback() { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       const params = new URLSearchParams(window.location.search); | 
					
						
							|  |  |  |       return params.has("code") || params.has("error"); | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function isDirectLogin() { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       const params = new URLSearchParams(window.location.search); | 
					
						
							|  |  |  |       return params.has("direct") && params.get("direct") === "1"; | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-05 16:12:11 -05:00
										 |  |  |     async function oidcAuthenticate(callback = false) { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       if (callback) { | 
					
						
							|  |  |  |         oidcLoggingIn.value = true; | 
					
						
							|  |  |  |         try { | 
					
						
							|  |  |  |           await $auth.oauthSignIn(); | 
					
						
							|  |  |  |           window.location.href = "/"; // Reload the app to get the new user
 | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         catch (error) { | 
					
						
							|  |  |  |           await router.replace("/login?direct=1"); | 
					
						
							|  |  |  |           alertOnError(error); | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         oidcLoggingIn.value = false; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							|  |  |  |         navigateTo("/api/auth/oauth", { external: true }); // start the redirect process
 | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |     async function authenticate() { | 
					
						
							| 
									
										
										
										
											2022-02-20 15:14:31 -09:00
										 |  |  |       if (form.email.length === 0 || form.password.length === 0) { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         alert.error(i18n.t("user.please-enter-your-email-and-password")); | 
					
						
							| 
									
										
										
										
											2022-02-20 15:14:31 -09:00
										 |  |  |         return; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |       loggingIn.value = true; | 
					
						
							|  |  |  |       const formData = new FormData(); | 
					
						
							|  |  |  |       formData.append("username", form.email); | 
					
						
							|  |  |  |       formData.append("password", form.password); | 
					
						
							| 
									
										
										
										
											2021-12-04 16:06:24 -09:00
										 |  |  |       formData.append("remember_me", String(form.remember)); | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-20 14:30:38 -09:00
										 |  |  |       try { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         await $auth.signIn(formData, { redirect: false }); | 
					
						
							|  |  |  |         window.location.href = "/"; // Reload the app to get the new user
 | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       catch (error) { | 
					
						
							|  |  |  |         console.log(error); | 
					
						
							|  |  |  |         alertOnError(error); | 
					
						
							| 
									
										
										
										
											2024-10-05 16:12:11 -05:00
										 |  |  |       } | 
					
						
							|  |  |  |       loggingIn.value = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function alertOnError(error: any) { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       // TODO Check if error is an AxiosError, but isAxiosError is not working right now
 | 
					
						
							|  |  |  |       // See https://github.com/nuxt-community/axios-module/issues/550
 | 
					
						
							|  |  |  |       // Import $axios from useContext()
 | 
					
						
							|  |  |  |       // if ($axios.isAxiosError(error) && error.response?.status === 401) {
 | 
					
						
							|  |  |  |       if (error.response?.status === 401) { | 
					
						
							|  |  |  |         alert.error(i18n.t("user.invalid-credentials")); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       else if (error.response?.status === 423) { | 
					
						
							|  |  |  |         alert.error(i18n.t("user.account-locked-please-try-again-later")); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							|  |  |  |         alert.error(i18n.t("events.something-went-wrong")); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |     return { | 
					
						
							| 
									
										
										
										
											2022-03-15 17:34:53 -08:00
										 |  |  |       isDark, | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |       form, | 
					
						
							|  |  |  |       loggingIn, | 
					
						
							| 
									
										
										
										
											2025-09-27 12:26:02 -05:00
										 |  |  |       appInfoLoaded, | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |       allowSignup, | 
					
						
							| 
									
										
										
										
											2025-05-27 15:49:06 -04:00
										 |  |  |       allowPasswordLogin, | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |       allowOidc, | 
					
						
							| 
									
										
										
										
											2021-09-14 12:26:28 -08:00
										 |  |  |       authenticate, | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  |       oidcAuthenticate, | 
					
						
							|  |  |  |       oidcProviderName, | 
					
						
							| 
									
										
										
										
											2024-10-05 16:12:11 -05:00
										 |  |  |       oidcLoggingIn, | 
					
						
							| 
									
										
										
										
											2022-03-22 20:41:54 -08:00
										 |  |  |       passwordIcon, | 
					
						
							|  |  |  |       inputType, | 
					
						
							|  |  |  |       togglePasswordShow, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       isFirstLogin, | 
					
						
							| 
									
										
										
										
											2021-10-07 09:39:47 -08:00
										 |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  | </script> | 
					
						
							| 
									
										
										
										
											2021-10-02 12:18:01 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | <style lang="css"> | 
					
						
							|  |  |  | .max-button { | 
					
						
							|  |  |  |   width: 300px; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-23 15:04:45 -09:00
										 |  |  | .icon-white { | 
					
						
							|  |  |  |   fill: white; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-22 11:36:58 -09:00
										 |  |  | .icon-container { | 
					
						
							|  |  |  |   display: flex; | 
					
						
							|  |  |  |   flex-direction: column; | 
					
						
							|  |  |  |   align-items: center; | 
					
						
							|  |  |  |   width: 100%; | 
					
						
							|  |  |  |   position: relative; | 
					
						
							|  |  |  |   margin-top: 3.5rem; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .icon-divider { | 
					
						
							|  |  |  |   width: 100%; | 
					
						
							|  |  |  |   margin-bottom: -3.5rem; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .icon-avatar { | 
					
						
							|  |  |  |   border-color: rgba(0, 0, 0, 0.12); | 
					
						
							|  |  |  |   border: 2px; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-02-23 15:04:45 -09:00
										 |  |  | 
 | 
					
						
							|  |  |  | .bg-off-white { | 
					
						
							|  |  |  |   background: #f5f8fa; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | .absolute { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   position: absolute; | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .div-width { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   max-width: 75%; | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .bg-white { | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   background-color: #fff; | 
					
						
							| 
									
										
										
										
											2024-03-10 13:51:36 -05:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | </style> |