mirror of
https://github.com/docmost/docmost.git
synced 2026-07-23 06:52:47 +10:00
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:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user