Return user and with current workspace

* Create endpoint to return user and their workspace
* Only return auth tokens on login/signup
* Allow nullable workspace name
This commit is contained in:
Philipinho
2023-08-26 23:38:14 +01:00
parent da8ee065df
commit 3e7c2de9a4
8 changed files with 85 additions and 28 deletions
@@ -3,6 +3,7 @@ import { JwtService } from '@nestjs/jwt';
import { EnvironmentService } from '../../../environment/environment.service';
import { User } from '../../user/entities/user.entity';
import { FastifyRequest } from 'fastify';
import { TokensDto } from "../dto/tokens.dto";
@Injectable()
export class TokenService {
@@ -18,6 +19,13 @@ export class TokenService {
return await this.jwtService.signAsync(payload);
}
async generateTokens(user: User): Promise<TokensDto> {
return {
accessToken: await this.generateJwt(user),
refreshToken: null,
};
}
async verifyJwt(token: string) {
return await this.jwtService.verifyAsync(token, {
secret: this.environmentService.getJwtSecret(),