import { Component, OnInit } from "@angular/core"; import { Router } from '@angular/router'; import { User } from '@supabase/supabase-js'; import { SupaService } from './api/supabase/supa.service'; @Component({ selector: "app-root", templateUrl: "./app.component.html", styleUrls: ["./app.component.scss"] }) export class AppComponent implements OnInit { user: User; menuHidden: boolean = false; constructor( public supa: SupaService, private router: Router, ) { } async ngOnInit() { try { this.user = await this.supa.client.auth.user(); } catch (e) { console.log(e.msg); this.router.navigate(['/login']); } } async logout() { try { await this.supa.logout(); this.router.navigate(['/login']); } catch (e) { console.error(e); } } }