-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[back] 💾 database: add default admin user with email and password
- Loading branch information
1 parent
fd8c86c
commit 7b21f8f
Showing
1 changed file
with
11 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import { | |
SuppliersFaker, | ||
UsersFaker, | ||
} from '@stocker/core/fakers' | ||
import { CryptoProvider } from '@/providers/crypto-provider' | ||
|
||
const FAKE_COMPANY_ID = '29fcf7a0-5ee3-4cb0-b36e-ecc825f1cdaa' | ||
|
||
|
@@ -60,7 +61,8 @@ export async function registerInboundMovement( | |
} | ||
|
||
export async function seed() { | ||
await resetDatabase() | ||
const existingFakeCompany = await companiesRepository.findById(FAKE_COMPANY_ID) | ||
if (existingFakeCompany) await companiesRepository.delete(FAKE_COMPANY_ID) | ||
|
||
const fakeCompany = CompanyFaker.fake({ id: FAKE_COMPANY_ID }) | ||
const fakeSuppliers = SuppliersFaker.fakeMany(3, { companyId: fakeCompany.id }) | ||
|
@@ -94,7 +96,14 @@ export async function seed() { | |
role: 'employee', | ||
companyId: fakeCompany.id, | ||
}) | ||
fakeUsers.push(UsersFaker.fake({ role: 'admin', companyId: fakeCompany.id })) | ||
fakeUsers.push( | ||
UsersFaker.fake({ | ||
role: 'admin', | ||
companyId: fakeCompany.id, | ||
email: '[email protected]', | ||
password: await new CryptoProvider().hash('stocker123'), | ||
}), | ||
) | ||
|
||
await companiesRepository.add(fakeCompany) | ||
|
||
|