added new guard for protected routes, fix tooltip for sidemenu
This commit is contained in:
parent
cf29c1c9bb
commit
1add1e573f
|
@ -1 +1,2 @@
|
||||||
export * from './local.auth.guard';
|
export * from './local.auth.guard';
|
||||||
|
export * from './is-authenticated.guard';
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
||||||
|
|
||||||
|
export class IsAuthenticatedGuard implements CanActivate {
|
||||||
|
public canActivate(context: ExecutionContext): boolean {
|
||||||
|
const request = context.switchToHttp().getRequest();
|
||||||
|
|
||||||
|
return request.isAuthenticated();
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,12 +12,13 @@ export class SigninResponseDto {
|
||||||
@IsEmail()
|
@IsEmail()
|
||||||
public email: string;
|
public email: string;
|
||||||
|
|
||||||
@ApiProperty({
|
// TODO: ID is saved in the session, so it is not needed here
|
||||||
title: 'User ID',
|
// @ApiProperty({
|
||||||
description: 'User ID',
|
// title: 'User ID',
|
||||||
})
|
// description: 'User ID',
|
||||||
@IsNotEmpty()
|
// })
|
||||||
@IsString()
|
// @IsNotEmpty()
|
||||||
@IsEmail()
|
// @IsString()
|
||||||
public id: string;
|
// @IsEmail()
|
||||||
|
// public id: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ export class AuthService {
|
||||||
existingUser.id
|
existingUser.id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO: Add OTP or 2FA here as an additional security measure
|
||||||
await this.passwordConfirmationMailService.sendLoginLinkEmail(
|
await this.passwordConfirmationMailService.sendLoginLinkEmail(
|
||||||
magiclink.email,
|
magiclink.email,
|
||||||
token
|
token
|
||||||
|
@ -202,8 +203,8 @@ export class AuthService {
|
||||||
public getLoginResponse(
|
public getLoginResponse(
|
||||||
user: SigninResponseDto & { userAgent: string }
|
user: SigninResponseDto & { userAgent: string }
|
||||||
): SigninResponseDto {
|
): SigninResponseDto {
|
||||||
const { id, email }: SigninResponseDto = user;
|
const { email }: SigninResponseDto = user;
|
||||||
const responseData: SigninResponseDto = { id, email };
|
const responseData: SigninResponseDto = { email };
|
||||||
|
|
||||||
return responseData;
|
return responseData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
? 'compact'
|
? 'compact'
|
||||||
: 'closed'
|
: 'closed'
|
||||||
"
|
"
|
||||||
class="h-full overflow-hidden transition-transform duration-300 ease-in-out bg-primary text-primary-content flex flex-col lg:translate-x-0"
|
class="h-full transition-transform duration-300 ease-in-out bg-primary text-primary-content flex flex-col lg:translate-x-0"
|
||||||
[ngClass]="{
|
[ngClass]="{
|
||||||
'w-16': isCompact && !isDrawerOpen,
|
'w-16': isCompact && !isDrawerOpen,
|
||||||
'w-64': isDrawerOpen,
|
'w-64': isDrawerOpen,
|
||||||
|
@ -383,13 +383,15 @@
|
||||||
(keydown.space)="toggleDrawer()"></div>
|
(keydown.space)="toggleDrawer()"></div>
|
||||||
|
|
||||||
<!-- Hauptinhalt -->
|
<!-- Hauptinhalt -->
|
||||||
<div class="flex-1 overflow-y-auto bg-base-100">
|
<div
|
||||||
<main [ngStyle]="mainContent" class="flex-1 w-full h-full">
|
class="flex-1 overflow-y-auto bg-base-100 transition-all duration-200 ease-in-out"
|
||||||
<div class="w-full h-full flex">
|
[ngClass]="{
|
||||||
<div class="w-full">
|
'ml-16 lg:ml-0': isCompact && isMobile,
|
||||||
<router-outlet></router-outlet>
|
'ml-64 lg:ml-0': !isCompact && isDrawerOpen && isMobile,
|
||||||
</div>
|
'ml-0': (!isDrawerOpen && !isCompact) || !isMobile
|
||||||
</div>
|
}">
|
||||||
|
<main [ngStyle]="mainContent" class="w-full h-full p-4">
|
||||||
|
<router-outlet></router-outlet>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue