mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-11-10 00:23:58 +00:00
auth with cookies.
This commit is contained in:
parent
cf300cb1b7
commit
b062e14c9a
|
@ -61,7 +61,7 @@ form{
|
|||
}
|
||||
.btn_signin{
|
||||
transition: all .5s ease;
|
||||
width: 70%;
|
||||
width: 100%;
|
||||
border-radius: 30px;
|
||||
color:#008080;
|
||||
font-weight: 600;
|
||||
|
|
|
@ -32,7 +32,6 @@ export class RegistrationComponent implements OnInit {
|
|||
get me() { return this.form.controls; }
|
||||
|
||||
onSubmit() {
|
||||
console.log(this.form.value);
|
||||
this.api.registerUser(this.form.value.username, this.form.value.password, this.form.value.email).subscribe(res=>console.log(res));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ form{
|
|||
}
|
||||
.btn_signin{
|
||||
transition: all .5s ease;
|
||||
width: 70%;
|
||||
width: 100%;
|
||||
border-radius: 30px;
|
||||
color:#008080;
|
||||
font-weight: 600;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<h2>Anmelden</h2>
|
||||
</div>
|
||||
<div class="row">
|
||||
<form [formGroup]="form" class="form-group" (ngSubmit)="onSubmit()">
|
||||
<form [formGroup]="loginForm" class="form-group" (ngSubmit)="onSubmit()">
|
||||
<div class="row">
|
||||
<input type="text" formControlName="username" name="username" id="username" class="form__input" placeholder="Username">
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import {FormBuilder, Validators} from "@angular/forms";
|
||||
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
|
||||
import {ApiService} from "../../../services/api.service";
|
||||
import {Router} from "@angular/router";
|
||||
|
||||
@Component({
|
||||
selector: 'app-signin',
|
||||
|
@ -10,22 +11,45 @@ import {ApiService} from "../../../services/api.service";
|
|||
|
||||
export class SigninComponent implements OnInit {
|
||||
|
||||
form: any;
|
||||
loginForm: FormGroup;
|
||||
loading = false;
|
||||
submitted = false;
|
||||
private isSuccessful: boolean;
|
||||
private isSignUpFailed: boolean;
|
||||
private errorMessage: '';
|
||||
|
||||
|
||||
constructor(
|
||||
private formBuilder: FormBuilder,
|
||||
private api : ApiService
|
||||
private api: ApiService,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.form = this.formBuilder.group({
|
||||
email: ['', Validators.required],
|
||||
password: ['', Validators.required]
|
||||
this.loginForm = this.formBuilder.group({
|
||||
username: ['', Validators.required],
|
||||
password: ['', [Validators.required, Validators.minLength(8)]]
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
console.log(this.form.value);
|
||||
this.api.loginUser(this.form.value.username, this.form.value.password);
|
||||
|
||||
this.submitted = true;
|
||||
|
||||
if (this.loginForm.invalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.api.loginUser(this.loginForm.value.username, this.loginForm.value.password)
|
||||
.subscribe(
|
||||
data => {
|
||||
this.router.navigate(['']);
|
||||
this.isSuccessful = true;
|
||||
this.isSignUpFailed = false;
|
||||
},
|
||||
err => {
|
||||
this.errorMessage = err.error.message;
|
||||
this.isSignUpFailed = true;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import {ApiService} from "../../services/api.service";
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-top-bar',
|
||||
|
@ -9,9 +11,12 @@ export class TopBarComponent implements OnInit {
|
|||
|
||||
sidenav: any;
|
||||
|
||||
constructor() { }
|
||||
constructor(
|
||||
private api: ApiService
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
this.api.getUserInfo().subscribe(data=>{console.log(data)});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user