[DEV] update to basic work

This commit is contained in:
Edouard DUPIN 2024-04-06 13:07:46 +02:00
parent 948816b0f7
commit 97242643b9
5 changed files with 26 additions and 32 deletions

View File

@ -16,7 +16,7 @@ export interface EventOnMenu {
}
@Component({
selector: 'app-top-menu',
selector: 'karcw-top-menu',
templateUrl: './top-menu.html',
styleUrls: ['./top-menu.less'],
})

View File

@ -2,11 +2,10 @@ import { PopInComponent, TopMenuComponent, UploadFileComponent, ErrorComponent,
import { PopInUploadProgress, PopInDeleteConfirm } from './popin';
export const ALL_COMPONENTS = [
TopMenuComponent,
PopInComponent,
PopInUploadProgress,
PopInDeleteConfirm,
TopMenuComponent,
UploadFileComponent,
ErrorComponent,
PasswordEntryComponent,

View File

@ -15,7 +15,7 @@ import { ALL_GUARDS } from "./kar-cw.guard";
@NgModule({
declarations: [
...ALL_COMPONENTS,
...ALL_SCENES,
//...ALL_SCENES,
],
imports: [
CommonModule,
@ -28,10 +28,10 @@ import { ALL_GUARDS } from "./kar-cw.guard";
],
exports: [
...ALL_COMPONENTS,
...ALL_SCENES,
//...ALL_SCENES,
//...ALL_SERVICES,
//...ALL_GUARDS,
],
//schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
})
export class KarCWModule { }

View File

@ -130,9 +130,10 @@ export class SessionService {
providedIn: 'root',
})
export class OnlyUsersGuard {
constructor(private sessionService: SessionService, private router: Router) { }
constructor(/*private sessionService: SessionService, */private router: Router) { }
canActivate() {
/*
console.log('OnlyLoggedInUsers');
if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin)) {
return true;
@ -140,6 +141,8 @@ export class OnlyUsersGuard {
this.router.navigateByUrl('/forbidden');
return false;
}
*/
return true;
}
}
@ -147,44 +150,50 @@ export class OnlyUsersGuard {
providedIn: 'root',
})
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)) {
return true;
} else {
this.router.navigateByUrl('/unregistered');
return false;
}
*/
return true;
}
}
@Injectable({
providedIn: 'root',
})
export class OnlyUnregisteredGuardHome {
constructor(private sessionService: SessionService, private router: Router) { }
constructor(/*private sessionService: SessionService, */private router: Router) { }
canActivate() {
canActivate() {/*
if (!this.sessionService.islogged()) {
return true;
} else {
this.router.navigateByUrl('/home');
return false;
}
*/
return true;
}
}
@Injectable({
providedIn: 'root',
})
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)) {
return true;
} else {
this.router.navigateByUrl('/forbidden');
return false;
}
*/
return true;
}
}

View File

@ -14,21 +14,7 @@ import { getApplicationLocation, isNullOrUndefined, sha512 } from '../utils';
import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf';
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({
providedIn: 'root',
})
@ -73,14 +59,14 @@ export class UserService {
}
// const tokenHeader = decodeURIComponent(window.atob( elems[0] ));
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);
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 nowTime = new Date();
// TODO: set a marging of 2 hours...
// TODO: set a margin of 2 hours...
return expireIn > nowTime;
}
@ -96,7 +82,7 @@ export class UserService {
const self = this;
return new Promise<void>((resolve, reject) => {
// 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;
// console.log("start Path-name: '" + pathName + "'");
// console.log("check with: '" + environment.applName + "/sso/" + "'");