2 Commits

Author SHA1 Message Date
Kola92
c2ecfd9dee authenticate company user 2023-04-26 14:42:11 +01:00
adekola
ba0f313770 Merge branch 'login-dev' of adekola/talenttic-crm-app into master 2023-04-25 17:20:26 +02:00
3 changed files with 36 additions and 12 deletions

View File

@@ -1,10 +1,26 @@
import { Component } from "@angular/core";
import { Component, OnInit } from "@angular/core";
import { Router } from "@angular/router";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"]
styleUrls: ["./app.component.scss"],
})
export class AppComponent {
export class AppComponent implements OnInit {
title = "black-dashboard-angular";
companyLocalStorage: any;
constructor(private router: Router) {
this.companyLocalStorage = JSON.parse(
localStorage.getItem("companyData") || "{}"
);
}
ngOnInit(): void {
if (this.companyLocalStorage) {
this.router.navigate(["/company-information"]);
} else {
this.router.navigate(["/login"]);
}
}
}

View File

@@ -1,4 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { Router } from "@angular/router";
@Component({
selector: "app-admin-layout",
@@ -7,8 +8,9 @@ import { Component, OnInit } from "@angular/core";
})
export class AdminLayoutComponent implements OnInit {
public sidebarColor: string = "red";
companyLocalStorage: any;
constructor() {}
constructor(private router: Router) {}
changeSidebarColor(color){
var sidebar = document.getElementsByClassName('sidebar')[0];
var mainPanel = document.getElementsByClassName('main-panel')[0];
@@ -31,5 +33,13 @@ export class AdminLayoutComponent implements OnInit {
body.classList.remove('white-content');
}
}
ngOnInit() {}
ngOnInit() {
this.companyLocalStorage = JSON.parse(localStorage.getItem('companyData') || "{}")
if(this.companyLocalStorage) {
this.router.navigate(['/company-information'])
} else {
this.router.navigate(['/login'])
}
}
}

View File

@@ -32,11 +32,7 @@ export class LoginComponent implements OnInit {
password: ["", [Validators.required, Validators.minLength(6)]],
});
this.companyService
.getCompanyById(1)
.subscribe((company) => {
this.companyService.getCompanyById(1).subscribe((company) => {
this.company = company;
});
}
@@ -82,6 +78,8 @@ export class LoginComponent implements OnInit {
setTimeout(() => {
this.router.navigate(["/company-information"]);
}, 1000);
} else {
this.router.navigate(["/login"]);
}
this.loginForm.reset();