fix: rediret naar user page als user al ingelogd is ipv witte pagina met logout
This commit is contained in:
		
							parent
							
								
									0cccc90dfe
								
							
						
					
					
						commit
						ddfdb94935
					
				
					 1 changed files with 14 additions and 7 deletions
				
			
		|  | @ -1,6 +1,20 @@ | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
|  |     import { useRouter } from "vue-router"; | ||||||
|     import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg"; |     import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg"; | ||||||
|     import auth from "@/services/auth/auth-service.ts"; |     import auth from "@/services/auth/auth-service.ts"; | ||||||
|  |     import { watch } from "vue"; | ||||||
|  | 
 | ||||||
|  |     const router = useRouter(); | ||||||
|  | 
 | ||||||
|  |     watch( | ||||||
|  |         () => auth.isLoggedIn.value, | ||||||
|  |         (newVal) => { | ||||||
|  |             if (newVal) { | ||||||
|  |                 router.push("/user"); | ||||||
|  |             } | ||||||
|  |         }, | ||||||
|  |         { immediate: true }, | ||||||
|  |     ); | ||||||
| 
 | 
 | ||||||
|     async function loginAsStudent(): Promise<void> { |     async function loginAsStudent(): Promise<void> { | ||||||
|         await auth.loginAs("student"); |         await auth.loginAs("student"); | ||||||
|  | @ -65,13 +79,6 @@ | ||||||
|                 </div> |                 </div> | ||||||
|             </ul> |             </ul> | ||||||
|         </div> |         </div> | ||||||
|         <div v-if="auth.isLoggedIn.value"> |  | ||||||
|             <p> |  | ||||||
|                 You are currently logged in as {{ auth.authState.user!.profile.name }} ({{ auth.authState.activeRole }}) |  | ||||||
|             </p> |  | ||||||
|             <v-btn @click="performLogout">Logout</v-btn> |  | ||||||
|             <v-btn to="/user">home</v-btn> |  | ||||||
|         </div> |  | ||||||
|     </main> |     </main> | ||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 laurejablonski
						laurejablonski