fix(server): create dev user (#7592)
This commit is contained in:
@@ -76,7 +76,7 @@ export class AuthService implements OnApplicationBootstrap {
|
|||||||
const [email, name, password] = ['dev@affine.pro', 'Dev User', 'dev'];
|
const [email, name, password] = ['dev@affine.pro', 'Dev User', 'dev'];
|
||||||
let devUser = await this.user.findUserByEmail(email);
|
let devUser = await this.user.findUserByEmail(email);
|
||||||
if (!devUser) {
|
if (!devUser) {
|
||||||
devUser = await this.user.createUser({
|
devUser = await this.user.createUser_without_verification({
|
||||||
email,
|
email,
|
||||||
name,
|
name,
|
||||||
password,
|
password,
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
import { Quota_FreePlanV1_1 } from '../quota/schema';
|
import { Quota_FreePlanV1_1 } from '../quota/schema';
|
||||||
import { validators } from '../utils/validators';
|
import { validators } from '../utils/validators';
|
||||||
|
|
||||||
|
type CreateUserInput = Omit<Prisma.UserCreateInput, 'name'> & { name?: string };
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserService {
|
export class UserService {
|
||||||
private readonly logger = new Logger(UserService.name);
|
private readonly logger = new Logger(UserService.name);
|
||||||
@@ -52,9 +54,7 @@ export class UserService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async createUser(
|
async createUser(data: CreateUserInput) {
|
||||||
data: Omit<Prisma.UserCreateInput, 'name'> & { name?: string }
|
|
||||||
) {
|
|
||||||
validators.assertValidEmail(data.email);
|
validators.assertValidEmail(data.email);
|
||||||
const user = await this.findUserByEmail(data.email);
|
const user = await this.findUserByEmail(data.email);
|
||||||
|
|
||||||
@@ -71,7 +71,13 @@ export class UserService {
|
|||||||
max: config['auth/password.max'],
|
max: config['auth/password.max'],
|
||||||
min: config['auth/password.min'],
|
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);
|
data.password = await this.crypto.encryptPassword(data.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user