fix seeds
This commit is contained in:
@@ -20,21 +20,23 @@ export class EnsureInitialData {
|
||||
|
||||
async execute(): Promise<void> {
|
||||
// Ensure initial admin user exists
|
||||
try {
|
||||
await this.signupUseCase.execute({
|
||||
email: 'admin@gridpilot.local',
|
||||
password: 'admin123',
|
||||
displayName: 'Admin',
|
||||
});
|
||||
const signupResult = await this.signupUseCase.execute({
|
||||
email: 'admin@gridpilot.local',
|
||||
password: 'admin123',
|
||||
displayName: 'Admin',
|
||||
});
|
||||
|
||||
if (signupResult.isOk()) {
|
||||
this.logger.info('[Bootstrap] Initial admin user created');
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message === 'An account with this email already exists') {
|
||||
// User already exists, nothing to do
|
||||
this.logger.info('[Bootstrap] Admin user already exists');
|
||||
} else {
|
||||
// Re-throw other errors
|
||||
throw error;
|
||||
}
|
||||
} else if (signupResult.error?.code === 'EMAIL_ALREADY_EXISTS') {
|
||||
this.logger.info('[Bootstrap] Admin user already exists');
|
||||
} else {
|
||||
const detailsMessage =
|
||||
signupResult.error && typeof signupResult.error === 'object' && 'details' in signupResult.error
|
||||
? (signupResult.error as { details?: { message?: string } }).details?.message
|
||||
: undefined;
|
||||
|
||||
throw new Error(detailsMessage ?? 'Failed to ensure initial admin user');
|
||||
}
|
||||
|
||||
// Ensure initial achievements exist
|
||||
|
||||
Reference in New Issue
Block a user