Ignore:
Timestamp:
12/19/21 19:39:00 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
bdd6491
Parents:
1ad8e64
Message:

spring security 2.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/src/app/homepage/homepage.component.ts

    r1ad8e64 r84d0fbb  
    11import { Component, OnInit } from '@angular/core';
     2import { Router } from '@angular/router';
    23import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
     4import { LoginRequest } from '../_models/dto/loginRequest';
     5import { UserDto } from '../_models/dto/userDto';
    36import { Location } from '../_models/location';
    47import { LocationService } from '../_services/location.service';
     8import { UserService } from '../_services/user.service';
     9import { LoginComponent } from './login/login.component';
    510import { RegisterComponent } from './register/register.component';
    611
     
    2025   ref: DynamicDialogRef;
    2126
    22    constructor(private locationService: LocationService, private dialogService: DialogService) {
     27   constructor(private locationService: LocationService, private dialogService: DialogService, private userService: UserService,
     28      private router: Router) {
    2329      this.responsiveOptions = [
    2430         {
     
    4450
    4551   ngOnInit(): void {
    46 
     52/*
    4753      this.locationService.getWeekendGetaways().subscribe(
    4854         data => {
     
    5561         }
    5662      );
     63      */
    5764   }
    5865
    59    onClickSignUp(){
    60       console.log("VLEGOV");
     66   onClickSignUp() {
    6167      this.ref = this.dialogService.open(RegisterComponent, {
    6268         header: 'Register form',
     
    6470         contentStyle: { "max-height": "500px", "overflow": "auto" },
    6571         baseZIndex: 10000
    66        });
     72      });
     73
     74      this.ref.onClose.subscribe((user: UserDto) => {
     75         this.userService.registerUser(user).subscribe(
     76            data  => {
     77               console.log(data);
     78             
     79            }
     80         );
     81      });
     82   }
     83
     84   
     85   onClickLogIn() {
     86      this.ref = this.dialogService.open(LoginComponent, {
     87         header: 'Log in if you already have an account',
     88         width: '70%',
     89         contentStyle: { "max-height": "500px", "overflow": "auto" },
     90         baseZIndex: 10000
     91      });
     92      this.ref.onClose.subscribe((loginRequest : LoginRequest) => {
     93         this.userService.authenticateUser(loginRequest).subscribe(
     94            (data : any)  => {
     95               console.log(data);
     96               if(this.userService.isUserLoggedIn()){
     97                  this.router.navigate(['planners']);
     98               }
     99            }
     100         );
     101      });
    67102   }
    68103}
Note: See TracChangeset for help on using the changeset viewer.