Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 10.8.5 #389

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 58 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lenne.tech/nest-server",
"version": "10.8.4",
"version": "10.8.5",
"description": "Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).",
"keywords": [
"node",
Expand Down Expand Up @@ -75,6 +75,7 @@
"@nestjs/passport": "10.0.3",
"@nestjs/platform-express": "10.4.15",
"@nestjs/schedule": "4.1.2",
"@nestjs/swagger": "8.1.1",
"@nestjs/terminus": "10.3.0",
"apollo-server-core": "3.13.0",
"apollo-server-express": "3.13.0",
Expand Down
2 changes: 1 addition & 1 deletion spectaql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ servers:
info:
title: lT Nest Server
description: Modern, fast, powerful Node.js web framework in TypeScript based on Nest with a GraphQL API and a connection to MongoDB (or other databases).
version: 10.8.4
version: 10.8.5
contact:
name: lenne.Tech GmbH
url: https://lenne.tech
Expand Down
27 changes: 16 additions & 11 deletions src/core/modules/auth/core-auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Controller, Get, Param, ParseBoolPipe, Post, Res, UseGuards } from '@nestjs/common';
import { Args } from '@nestjs/graphql';
import { Body, Controller, Get, ParseBoolPipe, Post, Query, Res, UseGuards } from '@nestjs/common';
import { ApiBody, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { Response as ResponseType } from 'express';

import { CurrentUser } from '../../common/decorators/current-user.decorator';
Expand Down Expand Up @@ -29,14 +29,15 @@ export class CoreAuthController {
/**
* Logout user (from specific device)
*/
@ApiOperation({ description: 'Logs a user out from a specific device' })
@Get('logout')
@Roles(RoleEnum.S_EVERYONE)
@UseGuards(AuthGuard(AuthGuardStrategy.JWT))
@Get()
async logout(
@CurrentUser() currentUser: ICoreAuthUser,
@Tokens('token') token: string,
@Res() res: ResponseType,
@Param('allDevices', ParseBoolPipe) allDevices?: boolean,
@Res({ passthrough: true }) res: ResponseType,
@Query('allDevices', ParseBoolPipe) allDevices?: boolean,
): Promise<boolean> {
const result = await this.authService.logout(token, { allDevices, currentUser });
return this.processCookies(res, result);
Expand All @@ -45,13 +46,14 @@ export class CoreAuthController {
/**
* Refresh token (for specific device)
*/
@ApiResponse({ type: CoreAuthModel })
@Get('refresh-token')
@Roles(RoleEnum.S_EVERYONE)
@UseGuards(AuthGuard(AuthGuardStrategy.JWT_REFRESH))
@Get()
async refreshToken(
@CurrentUser() user: ICoreAuthUser,
@Tokens('refreshToken') refreshToken: string,
@Res() res: ResponseType,
@Res({ passthrough: true }) res: ResponseType,
): Promise<CoreAuthModel> {
const result = await this.authService.refreshTokens(user, refreshToken);
return this.processCookies(res, result);
Expand All @@ -60,19 +62,22 @@ export class CoreAuthController {
/**
* Sign in user via email and password (on specific device)
*/
@ApiOperation({ description: 'Sign in via email and password' })
@Post('signin')
@Roles(RoleEnum.S_EVERYONE)
@Post()
async signIn(@Res() res: ResponseType, @Body('input') input: CoreAuthSignInInput): Promise<CoreAuthModel> {
async signIn(@Res({ passthrough: true }) res: ResponseType, @Body() input: CoreAuthSignInInput): Promise<CoreAuthModel> {
const result = await this.authService.signIn(input);
return this.processCookies(res, result);
}

/**
* Register a new user account (on specific device)
*/
@ApiBody({ type: CoreAuthSignUpInput })
@ApiOperation({ description: 'Sign up via email and password' })
@Post('signup')
@Roles(RoleEnum.S_EVERYONE)
@Post()
async signUp(@Res() res: ResponseType, @Args('input') input: CoreAuthSignUpInput): Promise<CoreAuthModel> {
async signUp(@Res() res: ResponseType, @Body() input: CoreAuthSignUpInput): Promise<CoreAuthModel> {
const result = await this.authService.signUp(input);
return this.processCookies(res, result);
}
Expand Down
20 changes: 17 additions & 3 deletions src/core/modules/auth/core-auth.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Field, ObjectType } from '@nestjs/graphql';
import { ApiProperty } from '@nestjs/swagger';

import { Restricted } from '../../common/decorators/restricted.decorator';
import { RoleEnum } from '../../common/enums/role.enum';
Expand All @@ -18,22 +19,35 @@ export class CoreAuthModel extends CoreModel {
/**
* JavaScript Web Token (JWT)
*/
@Restricted(RoleEnum.S_EVERYONE)
@ApiProperty({
description: 'JavaScript Web Token (JWT) used for auth',
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
})
@Field({ description: 'JavaScript Web Token (JWT)', nullable: true })
@Restricted(RoleEnum.S_EVERYONE)
token?: string = undefined;

/**
* Refresh token
*/
@Restricted(RoleEnum.S_EVERYONE)
@ApiProperty({
description: 'Refresh JavaScript Web Token (JWT) used for auth',
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
})
@Field({ description: 'Refresh token', nullable: true })
@Restricted(RoleEnum.S_EVERYONE)
refreshToken?: string = undefined;

/**
* Current user
*/
@Restricted(RoleEnum.S_EVERYONE)
@ApiProperty({
description: 'User who signed in',
required: true,
type: () => CoreUserModel,
})
@Field({ description: 'Current user' })
@Restricted(RoleEnum.S_EVERYONE)
user: CoreUserModel = undefined;

// ===================================================================================================================
Expand Down
22 changes: 18 additions & 4 deletions src/core/modules/auth/inputs/core-auth-sign-in.input.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Field, InputType } from '@nestjs/graphql';
import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsNotEmpty, IsOptional, IsString } from 'class-validator';

import { Restricted } from '../../../common/decorators/restricted.decorator';
import { RoleEnum } from '../../../common/enums/role.enum';
Expand All @@ -14,19 +16,31 @@ export class CoreAuthSignInInput extends CoreInput {
// Properties
// ===================================================================================================================

@Restricted(RoleEnum.S_EVERYONE)
@ApiProperty()
@Field({ description: 'Device ID (is created automatically if it is not set)', nullable: true })
@IsOptional()
@IsString()
@Restricted(RoleEnum.S_EVERYONE)
deviceId?: string = undefined;

@Restricted(RoleEnum.S_EVERYONE)
@ApiProperty()
@Field({ description: 'Device description', nullable: true })
@IsOptional()
@IsString()
@Restricted(RoleEnum.S_EVERYONE)
deviceDescription?: string = undefined;

@Restricted(RoleEnum.S_EVERYONE)
@ApiProperty()
@Field({ description: 'Email', nullable: false })
@IsEmail()
@IsNotEmpty()
@Restricted(RoleEnum.S_EVERYONE)
email: string = undefined;

@Restricted(RoleEnum.S_EVERYONE)
@ApiProperty()
@Field({ description: 'Password', nullable: false })
@IsNotEmpty()
@IsString()
@Restricted(RoleEnum.S_EVERYONE)
password: string = undefined;
}
Loading