mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-02 14:33:54 +03:00
fix(server): create dev user (#7592)
This commit is contained in:
parent
9d446469f8
commit
25b74467ce
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user