3 Commits

Author SHA1 Message Date
adekola
4e6d96432a Merge branch 'auth-company' of adekola/talenttic-crm-app into master 2023-04-26 16:52:20 +02:00
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({ @Component({
selector: "app-root", selector: "app-root",
templateUrl: "./app.component.html", templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"] styleUrls: ["./app.component.scss"],
}) })
export class AppComponent { export class AppComponent implements OnInit {
title = "black-dashboard-angular"; 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 { Component, OnInit } from "@angular/core";
import { Router } from "@angular/router";
@Component({ @Component({
selector: "app-admin-layout", selector: "app-admin-layout",
@@ -7,8 +8,9 @@ import { Component, OnInit } from "@angular/core";
}) })
export class AdminLayoutComponent implements OnInit { export class AdminLayoutComponent implements OnInit {
public sidebarColor: string = "red"; public sidebarColor: string = "red";
companyLocalStorage: any;
constructor() {} constructor(private router: Router) {}
changeSidebarColor(color){ changeSidebarColor(color){
var sidebar = document.getElementsByClassName('sidebar')[0]; var sidebar = document.getElementsByClassName('sidebar')[0];
var mainPanel = document.getElementsByClassName('main-panel')[0]; var mainPanel = document.getElementsByClassName('main-panel')[0];
@@ -31,5 +33,13 @@ export class AdminLayoutComponent implements OnInit {
body.classList.remove('white-content'); 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,13 +32,9 @@ export class LoginComponent implements OnInit {
password: ["", [Validators.required, Validators.minLength(6)]], password: ["", [Validators.required, Validators.minLength(6)]],
}); });
this.companyService.getCompanyById(1).subscribe((company) => {
this.company = company;
this.companyService });
.getCompanyById(1)
.subscribe((company) => {
this.company = company;
});
} }
get formControls() { get formControls() {
@@ -82,6 +78,8 @@ export class LoginComponent implements OnInit {
setTimeout(() => { setTimeout(() => {
this.router.navigate(["/company-information"]); this.router.navigate(["/company-information"]);
}, 1000); }, 1000);
} else {
this.router.navigate(["/login"]);
} }
this.loginForm.reset(); this.loginForm.reset();