[DEV] update to basic work
This commit is contained in:
parent
948816b0f7
commit
97242643b9
@ -16,7 +16,7 @@ export interface EventOnMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-top-menu',
|
selector: 'karcw-top-menu',
|
||||||
templateUrl: './top-menu.html',
|
templateUrl: './top-menu.html',
|
||||||
styleUrls: ['./top-menu.less'],
|
styleUrls: ['./top-menu.less'],
|
||||||
})
|
})
|
||||||
|
@ -2,11 +2,10 @@ import { PopInComponent, TopMenuComponent, UploadFileComponent, ErrorComponent,
|
|||||||
import { PopInUploadProgress, PopInDeleteConfirm } from './popin';
|
import { PopInUploadProgress, PopInDeleteConfirm } from './popin';
|
||||||
|
|
||||||
export const ALL_COMPONENTS = [
|
export const ALL_COMPONENTS = [
|
||||||
|
TopMenuComponent,
|
||||||
PopInComponent,
|
PopInComponent,
|
||||||
PopInUploadProgress,
|
PopInUploadProgress,
|
||||||
PopInDeleteConfirm,
|
PopInDeleteConfirm,
|
||||||
|
|
||||||
TopMenuComponent,
|
|
||||||
UploadFileComponent,
|
UploadFileComponent,
|
||||||
ErrorComponent,
|
ErrorComponent,
|
||||||
PasswordEntryComponent,
|
PasswordEntryComponent,
|
||||||
|
@ -15,7 +15,7 @@ import { ALL_GUARDS } from "./kar-cw.guard";
|
|||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
...ALL_COMPONENTS,
|
...ALL_COMPONENTS,
|
||||||
...ALL_SCENES,
|
//...ALL_SCENES,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
@ -28,10 +28,10 @@ import { ALL_GUARDS } from "./kar-cw.guard";
|
|||||||
],
|
],
|
||||||
exports: [
|
exports: [
|
||||||
...ALL_COMPONENTS,
|
...ALL_COMPONENTS,
|
||||||
...ALL_SCENES,
|
//...ALL_SCENES,
|
||||||
//...ALL_SERVICES,
|
//...ALL_SERVICES,
|
||||||
//...ALL_GUARDS,
|
//...ALL_GUARDS,
|
||||||
],
|
],
|
||||||
//schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
|
||||||
})
|
})
|
||||||
export class KarCWModule { }
|
export class KarCWModule { }
|
||||||
|
@ -130,9 +130,10 @@ export class SessionService {
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class OnlyUsersGuard {
|
export class OnlyUsersGuard {
|
||||||
constructor(private sessionService: SessionService, private router: Router) { }
|
constructor(/*private sessionService: SessionService, */private router: Router) { }
|
||||||
|
|
||||||
canActivate() {
|
canActivate() {
|
||||||
|
/*
|
||||||
console.log('OnlyLoggedInUsers');
|
console.log('OnlyLoggedInUsers');
|
||||||
if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin)) {
|
if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin)) {
|
||||||
return true;
|
return true;
|
||||||
@ -140,6 +141,8 @@ export class OnlyUsersGuard {
|
|||||||
this.router.navigateByUrl('/forbidden');
|
this.router.navigateByUrl('/forbidden');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,44 +150,50 @@ export class OnlyUsersGuard {
|
|||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class OnlyUsersGuardHome {
|
export class OnlyUsersGuardHome {
|
||||||
constructor(private sessionService: SessionService, private router: Router) { }
|
constructor(/*private sessionService: SessionService, */private router: Router) { }
|
||||||
|
|
||||||
canActivate() {
|
canActivate() {/*
|
||||||
if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin)) {
|
if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.router.navigateByUrl('/unregistered');
|
this.router.navigateByUrl('/unregistered');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class OnlyUnregisteredGuardHome {
|
export class OnlyUnregisteredGuardHome {
|
||||||
constructor(private sessionService: SessionService, private router: Router) { }
|
constructor(/*private sessionService: SessionService, */private router: Router) { }
|
||||||
|
|
||||||
canActivate() {
|
canActivate() {/*
|
||||||
if (!this.sessionService.islogged()) {
|
if (!this.sessionService.islogged()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.router.navigateByUrl('/home');
|
this.router.navigateByUrl('/home');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class OnlyAdminGuard {
|
export class OnlyAdminGuard {
|
||||||
constructor(private sessionService: SessionService, private router: Router) { }
|
constructor(/*private sessionService: SessionService, */private router: Router) { }
|
||||||
|
|
||||||
canActivate() {
|
canActivate() {/*
|
||||||
if (this.sessionService.hasRight(UserRoles222.user)) {
|
if (this.sessionService.hasRight(UserRoles222.user)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this.router.navigateByUrl('/forbidden');
|
this.router.navigateByUrl('/forbidden');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,21 +14,7 @@ import { getApplicationLocation, isNullOrUndefined, sha512 } from '../utils';
|
|||||||
import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf';
|
import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf';
|
||||||
import { EnvironmentService } from '../model/environment';
|
import { EnvironmentService } from '../model/environment';
|
||||||
|
|
||||||
/*
|
|
||||||
interface MessageLogIn {
|
|
||||||
login: string;
|
|
||||||
method: string;
|
|
||||||
time: number;
|
|
||||||
password: string;
|
|
||||||
}
|
|
||||||
interface MessageAnswer_USER_CONNECT {
|
|
||||||
sessionId: string;
|
|
||||||
login: string;
|
|
||||||
eMail: string;
|
|
||||||
role: string;
|
|
||||||
avatar: string;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
@ -73,14 +59,14 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
// const tokenHeader = decodeURIComponent(window.atob( elems[0] ));
|
// const tokenHeader = decodeURIComponent(window.atob( elems[0] ));
|
||||||
const tokenData = decodeURIComponent(window.atob(elems[1]));
|
const tokenData = decodeURIComponent(window.atob(elems[1]));
|
||||||
// console.error(`Retreive local token: \nheader=${tokenHeader} \ndata=${tokenData}`);
|
// console.error(`Retrieve local token: \nheader=${tokenHeader} \ndata=${tokenData}`);
|
||||||
const parsedData = JSON.parse(tokenData);
|
const parsedData = JSON.parse(tokenData);
|
||||||
console.debug(
|
console.debug(
|
||||||
`Retreive token exp data=${new Date(parsedData.exp * 1000).toISOString()} < ${new Date().toISOString()}`
|
`Retrieve token exp data=${new Date(parsedData.exp * 1000).toISOString()} < ${new Date().toISOString()}`
|
||||||
);
|
);
|
||||||
const expireIn = new Date(parsedData.exp * 1000);
|
const expireIn = new Date(parsedData.exp * 1000);
|
||||||
const nowTime = new Date();
|
const nowTime = new Date();
|
||||||
// TODO: set a marging of 2 hours...
|
// TODO: set a margin of 2 hours...
|
||||||
return expireIn > nowTime;
|
return expireIn > nowTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +82,7 @@ export class UserService {
|
|||||||
const self = this;
|
const self = this;
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
// Need to use the windows global route to prevent the log in cycle ...
|
// Need to use the windows global route to prevent the log in cycle ...
|
||||||
// And in the mlain application position, the route does not have curently root the page
|
// And in the main application position, the route does not have currently root the page
|
||||||
let pathName = window.location.pathname;
|
let pathName = window.location.pathname;
|
||||||
// console.log("start Path-name: '" + pathName + "'");
|
// console.log("start Path-name: '" + pathName + "'");
|
||||||
// console.log("check with: '" + environment.applName + "/sso/" + "'");
|
// console.log("check with: '" + environment.applName + "/sso/" + "'");
|
||||||
|
Loading…
Reference in New Issue
Block a user