mirror of
https://github.com/docmost/docmost.git
synced 2025-11-12 16:12:39 +10:00
fix workspace setup
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { LoginDto } from '../dto/login.dto';
|
||||
import { CreateUserDto } from '../dto/create-user.dto';
|
||||
import { UserService } from '../../user/user.service';
|
||||
import { TokenService } from './token.service';
|
||||
import { TokensDto } from '../dto/tokens.dto';
|
||||
import { SignupService } from './signup.service';
|
||||
@ -12,14 +11,17 @@ import { comparePasswordHash } from '../../../helpers/utils';
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
constructor(
|
||||
private userService: UserService,
|
||||
private signupService: SignupService,
|
||||
private tokenService: TokenService,
|
||||
private userRepo: UserRepo,
|
||||
) {}
|
||||
|
||||
async login(loginDto: LoginDto, workspaceId: string) {
|
||||
const user = await this.userRepo.findByEmail(loginDto.email, workspaceId);
|
||||
const user = await this.userRepo.findByEmail(
|
||||
loginDto.email,
|
||||
workspaceId,
|
||||
true,
|
||||
);
|
||||
|
||||
if (
|
||||
!user ||
|
||||
|
||||
@ -2,7 +2,6 @@ import { BadRequestException, Injectable } from '@nestjs/common';
|
||||
import { CreateUserDto } from '../dto/create-user.dto';
|
||||
import { WorkspaceService } from '../../workspace/services/workspace.service';
|
||||
import { CreateWorkspaceDto } from '../../workspace/dto/create-workspace.dto';
|
||||
import { SpaceService } from '../../space/services/space.service';
|
||||
import { CreateAdminUserDto } from '../dto/create-admin-user.dto';
|
||||
import { GroupUserService } from '../../group/services/group-user.service';
|
||||
import { UserRepo } from '@docmost/db/repos/user/user.repo';
|
||||
@ -16,7 +15,6 @@ export class SignupService {
|
||||
constructor(
|
||||
private userRepo: UserRepo,
|
||||
private workspaceService: WorkspaceService,
|
||||
private spaceService: SpaceService,
|
||||
private groupUserService: GroupUserService,
|
||||
@InjectKysely() private readonly db: KyselyDB,
|
||||
) {}
|
||||
@ -63,7 +61,11 @@ export class SignupService {
|
||||
);
|
||||
}
|
||||
|
||||
async createWorkspace(user, workspaceName, trx?: KyselyTransaction) {
|
||||
async createWorkspace(
|
||||
user: User,
|
||||
workspaceName: string,
|
||||
trx?: KyselyTransaction,
|
||||
) {
|
||||
return await executeTx(
|
||||
this.db,
|
||||
async (trx) => {
|
||||
|
||||
@ -12,5 +12,5 @@ export class CreateGroupDto {
|
||||
}
|
||||
|
||||
export enum DefaultGroup {
|
||||
EVERYONE = 'users',
|
||||
EVERYONE = 'internal_users',
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ export class GroupUserService {
|
||||
await executeTx(
|
||||
this.db,
|
||||
async (trx) => {
|
||||
await this.groupService.findAndValidateGroup(groupId, workspaceId);
|
||||
// await this.groupService.findAndValidateGroup(groupId, workspaceId);
|
||||
const groupUserExists = await this.groupUserRepo.getGroupUserById(
|
||||
userId,
|
||||
groupId,
|
||||
|
||||
@ -5,15 +5,11 @@ import { PaginationMetaDto } from '../../../helpers/pagination/pagination-meta-d
|
||||
import { PaginatedResult } from '../../../helpers/pagination/paginated-result';
|
||||
import { UserRole } from '../../../helpers/types/permission';
|
||||
import { UserRepo } from '@docmost/db/repos/user/user.repo';
|
||||
import { WorkspaceRepo } from '@docmost/db/repos/workspace/workspace.repo';
|
||||
import { User } from '@docmost/db/types/entity.types';
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceUserService {
|
||||
constructor(
|
||||
private workspaceRepo: WorkspaceRepo,
|
||||
private userRepo: UserRepo,
|
||||
) {}
|
||||
constructor(private userRepo: UserRepo) {}
|
||||
|
||||
async getWorkspaceUsers(
|
||||
workspaceId: string,
|
||||
|
||||
@ -78,9 +78,8 @@ export class WorkspaceService {
|
||||
.execute();
|
||||
|
||||
// add user to default group
|
||||
await this.groupUserService.addUserToGroup(
|
||||
await this.groupUserService.addUserToDefaultGroup(
|
||||
user.id,
|
||||
group.id,
|
||||
workspace.id,
|
||||
trx,
|
||||
);
|
||||
@ -124,6 +123,7 @@ export class WorkspaceService {
|
||||
workspace.id,
|
||||
trx,
|
||||
);
|
||||
|
||||
return workspace;
|
||||
},
|
||||
trx,
|
||||
|
||||
@ -74,7 +74,6 @@ export class GroupRepo {
|
||||
.selectAll()
|
||||
.where('isDefault', '=', true)
|
||||
.where('workspaceId', '=', workspaceId)
|
||||
|
||||
.executeTakeFirst();
|
||||
},
|
||||
trx,
|
||||
|
||||
Reference in New Issue
Block a user