implement new invitation system

* fix comments on the frontend
* move jwt token service to its own module
* other fixes and updates
This commit is contained in:
Philipinho
2024-05-14 22:55:11 +01:00
parent 525990d6e5
commit eefe63d1cd
75 changed files with 10965 additions and 7846 deletions

View File

@ -4,42 +4,22 @@ import {
HttpCode,
HttpStatus,
Post,
UnauthorizedException,
UseGuards,
} from '@nestjs/common';
import { UserService } from './user.service';
import { UpdateUserDto } from './dto/update-user.dto';
import { AuthUser } from '../../decorators/auth-user.decorator';
import { JwtAuthGuard } from '../../guards/jwt-auth.guard';
import { UserRepo } from '@docmost/db/repos/user/user.repo';
import { AuthWorkspace } from '../../decorators/auth-workspace.decorator';
import { User, Workspace } from '@docmost/db/types/entity.types';
@UseGuards(JwtAuthGuard)
@Controller('users')
export class UserController {
constructor(
private readonly userService: UserService,
private userRepo: UserRepo,
) {}
constructor(private readonly userService: UserService) {}
@HttpCode(HttpStatus.OK)
@Post('me')
async getUser(
@AuthUser() authUser: User,
@AuthWorkspace() workspace: Workspace,
) {
const user = await this.userRepo.findById(authUser.id, workspace.id);
if (!user) {
throw new UnauthorizedException('Invalid user');
}
return user;
}
@HttpCode(HttpStatus.OK)
@Post('info')
async getUserIno(
@AuthUser() authUser: User,
@AuthWorkspace() workspace: Workspace,