36 lines
943 B
TypeScript
36 lines
943 B
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { SupaService } from '../api/supabase/supa.service';
|
|
|
|
@Component({
|
|
selector: 'app-signup',
|
|
templateUrl: './signup.component.html',
|
|
styleUrls: ['./signup.component.scss']
|
|
})
|
|
export class SignupComponent implements OnInit {
|
|
email: string = '';
|
|
password: string = '';
|
|
repeat: string = '';
|
|
|
|
constructor(
|
|
private supa: SupaService,
|
|
private router: Router,
|
|
) { }
|
|
|
|
ngOnInit(): void {
|
|
}
|
|
|
|
async signup(email: string, password: string, repeat: string) {
|
|
console.log(email, password, repeat);
|
|
if (!email || (email.length <= 0) || !password || (password.length <= 0) || !repeat || (repeat.length <= 0) || (password !== repeat)) {
|
|
return;
|
|
}
|
|
try {
|
|
await this.supa.signup(email, password);
|
|
this.router.navigate(['/']);
|
|
} catch (e) {
|
|
console.error('signup component', e);
|
|
}
|
|
}
|
|
|
|
}
|