-
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.
Merge pull request #50 from atlp-rwanda/fx-create-dummy-data-userAdmi…
…n-and-roles bug-fx create seeders for admin and role for admin
- Loading branch information
Showing
6 changed files
with
60 additions
and
6 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
'use strict'; | ||
const { v4: uuidv4 } = require('uuid'); | ||
|
||
/** @type {import('sequelize-cli').Seed} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
return queryInterface.bulkInsert( | ||
'Users', | ||
[ | ||
{ | ||
id: uuidv4(), | ||
firstName: 'admin', | ||
lastName: '', | ||
email: process.env.EMAIL, | ||
password: | ||
'$2b$10$ZCgzouXesg4Zqgj22u7ale5aAOJzmjfOchCpMlSgBMV8o2f.zdYUq', | ||
gender: 'not specified', | ||
phoneNumber: process.env.ADMIN_PHONE, | ||
verified: true, | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
status: 'active', | ||
RoleId: '6ef1e121-304a-4f08-ad4e-cd07f9578b52', // Replace with the actual RoleId | ||
}, | ||
], | ||
{} | ||
); | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
return queryInterface.bulkDelete('Users', null, {}); | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import bcrypt from 'bcrypt'; | ||
|
||
export const passwordEncrypt = async (password: string) => { | ||
const saltRound = await bcrypt.genSalt(12); | ||
const hashedPwd = await bcrypt.hash(password, saltRound); | ||
return hashedPwd; | ||
}; | ||
export const passwordCompare = async (password: string, inputPwd: string) => { | ||
return await bcrypt.compare(password, inputPwd); | ||
}; |