| 
									
										
										
										
											2021-07-31 14:00:28 -08:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  |   <div></div> | 
					
						
							| 
									
										
										
										
											2021-07-31 14:00:28 -08:00
										 |  |  | </template> | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  | import { computed, defineComponent, useAsync, useContext, useRouter } from "@nuxtjs/composition-api"; | 
					
						
							|  |  |  | import { useAsyncKey } from "~/composables/use-utils"; | 
					
						
							|  |  |  | import { AppInfo, AppStartupInfo } from "~/lib/api/types/admin"; | 
					
						
							| 
									
										
										
										
											2024-02-07 10:53:55 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | export default defineComponent({ | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  |   layout: "blank", | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  |   setup() { | 
					
						
							| 
									
										
										
										
											2024-02-07 10:53:55 -06:00
										 |  |  |     const { $auth, $axios } = useContext(); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  |     const router = useRouter(); | 
					
						
							|  |  |  |     const groupSlug = computed(() => $auth.user?.groupSlug); | 
					
						
							| 
									
										
										
										
											2023-02-19 17:13:29 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-07 10:53:55 -06:00
										 |  |  |     async function redirectPublicUserToDefaultGroup() { | 
					
						
							|  |  |  |       const { data } = await $axios.get<AppInfo>("/api/app/about"); | 
					
						
							|  |  |  |       if (data?.defaultGroupSlug) { | 
					
						
							|  |  |  |         router.push(`/g/${data.defaultGroupSlug}`); | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         router.push("/login"); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-11 08:28:54 -05:00
										 |  |  |     useAsync(async () => { | 
					
						
							|  |  |  |       if (groupSlug.value) { | 
					
						
							|  |  |  |         const data = await $axios.get<AppStartupInfo>("/api/app/about/startup-info"); | 
					
						
							|  |  |  |         const isDemo = data.data.isDemo; | 
					
						
							|  |  |  |         const isFirstLogin = data.data.isFirstLogin; | 
					
						
							|  |  |  |         if (!isDemo && isFirstLogin && $auth.user?.admin) { | 
					
						
							|  |  |  |           router.push("/admin/setup"); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           router.push(`/g/${groupSlug.value}`); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         redirectPublicUserToDefaultGroup(); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }, useAsyncKey()); | 
					
						
							| 
									
										
										
										
											2023-11-05 19:07:02 -06:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-07-31 15:07:19 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | </script> |