fix(server): create dev user (#7592)

This commit is contained in:
forehalo 2024-07-24 10:01:53 +00:00
parent 9d446469f8
commit 25b74467ce
No known key found for this signature in database
GPG Key ID: 56709255DC7EC728
2 changed files with 10 additions and 4 deletions

View File

@ -76,7 +76,7 @@ export class AuthService implements OnApplicationBootstrap {
const [email, name, password] = ['dev@affine.pro', 'Dev User', 'dev'];
let devUser = await this.user.findUserByEmail(email);
if (!devUser) {
devUser = await this.user.createUser({
devUser = await this.user.createUser_without_verification({
email,
name,
password,

View File

@ -14,6 +14,8 @@ import {
import { Quota_FreePlanV1_1 } from '../quota/schema';
import { validators } from '../utils/validators';
type CreateUserInput = Omit<Prisma.UserCreateInput, 'name'> & { name?: string };
@Injectable()
export class UserService {
private readonly logger = new Logger(UserService.name);
@ -52,9 +54,7 @@ export class UserService {
};
}
async createUser(
data: Omit<Prisma.UserCreateInput, 'name'> & { name?: string }
) {
async createUser(data: CreateUserInput) {
validators.assertValidEmail(data.email);
const user = await this.findUserByEmail(data.email);
@ -71,7 +71,13 @@ export class UserService {
max: config['auth/password.max'],
min: config['auth/password.min'],
});
}
return this.createUser_without_verification(data);
}
async createUser_without_verification(data: CreateUserInput) {
if (data.password) {
data.password = await this.crypto.encryptPassword(data.password);
}