-
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.
add employee field throughout files (#267)
* add employee field throughout files Co-authored-by: Gayatri Kondabathini <[email protected]> * replace isAdmin with scope * create migration for employee scope field * add scope to completeRegistration signature * fix format and tsc checks * add employee field throughout files Co-authored-by: Gayatri Kondabathini <[email protected]> * replace isAdmin with scope * create migration for employee scope field * add scope to completeRegistration signature * fix format and tsc checks * change api properties to enum and update completeRegistration signature * use correct scope type from client * fix tsc type in context type --------- Co-authored-by: Gayatri Kondabathini <[email protected]> Co-authored-by: Kaiyang Zheng <[email protected]>
- Loading branch information
1 parent
9449716
commit b5009f3
Showing
19 changed files
with
107 additions
and
37 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
apps/server/prisma/migrations/20250203024748_add_user_scope_field/migration.sql
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,12 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `isAdmin` on the `Employee` table. All the data in the column will be lost. | ||
*/ | ||
-- CreateEnum | ||
CREATE TYPE "EmployeeScope" AS ENUM ('BASE_USER', 'ADMIN'); | ||
|
||
-- AlterTable | ||
ALTER TABLE "Employee" DROP COLUMN "isAdmin", | ||
ADD COLUMN "scope" "EmployeeScope" NOT NULL DEFAULT 'BASE_USER'; |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { PrismaClient, SignerType } from '@prisma/client'; | ||
import { PrismaClient, SignerType, EmployeeScope } from '@prisma/client'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
@@ -49,6 +49,7 @@ type EmployeeData = { | |
email: string; | ||
positionId: string; | ||
signatureLink: string; | ||
scope: EmployeeScope; | ||
}; | ||
|
||
// update or insert employee to database based on the employee id | ||
|
@@ -65,6 +66,7 @@ async function upsertEmployee(empData: EmployeeData) { | |
position: { | ||
connect: { id: empData.positionId }, | ||
}, | ||
scope: empData.scope, | ||
}, | ||
}); | ||
} | ||
|
@@ -389,6 +391,7 @@ async function main() { | |
email: '[email protected]', | ||
positionId: CHIEF_OF_STAFF_UUID, | ||
signatureLink: DEV_SIGNATURE_LINK, | ||
scope: EmployeeScope.BASE_USER, | ||
}, | ||
{ | ||
id: KAI_ZHENG_UUID, | ||
|
@@ -397,6 +400,7 @@ async function main() { | |
email: '[email protected]', | ||
positionId: CHIEF_FIN_OFFICER_UUID, | ||
signatureLink: DEV_SIGNATURE_LINK, | ||
scope: EmployeeScope.BASE_USER, | ||
}, | ||
{ | ||
id: ANGELA_WEIGL_UUID, | ||
|
@@ -405,6 +409,7 @@ async function main() { | |
email: '[email protected]', | ||
positionId: AGG_DIR_UUID, | ||
signatureLink: DEV_SIGNATURE_LINK, | ||
scope: EmployeeScope.BASE_USER, | ||
}, | ||
{ | ||
id: ANSHUL_SHIRUDE_UUID, | ||
|
@@ -413,6 +418,7 @@ async function main() { | |
email: '[email protected]', | ||
positionId: CHIEF_LEARNING_ENGAGEMENT_UUID, | ||
signatureLink: DEV_SIGNATURE_LINK, | ||
scope: EmployeeScope.BASE_USER, | ||
}, | ||
]; | ||
|
||
|
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ import { EmployeeEntity } from '../employees/entities/employee.entity'; | |
import { PositionBaseEntity } from '../positions/entities/position.entity'; | ||
import { DepartmentsService } from '../departments/departments.service'; | ||
import { PositionsService } from '../positions/positions.service'; | ||
import { EmployeeScope } from '@prisma/client'; | ||
|
||
describe('AuthService', () => { | ||
let service: AuthService; | ||
|
@@ -60,7 +61,7 @@ describe('AuthService', () => { | |
updatedAt: new Date(1672531200), | ||
}, | ||
email: '[email protected]', | ||
isAdmin: false, | ||
scope: EmployeeScope.BASE_USER, | ||
pswdHash: 'password', | ||
createdAt: new Date(1672531200), | ||
updatedAt: new Date(1672531200), | ||
|
@@ -89,7 +90,7 @@ describe('AuthService', () => { | |
updatedAt: new Date(1672531200), | ||
}, | ||
email: '[email protected]', | ||
isAdmin: false, | ||
scope: EmployeeScope.BASE_USER, | ||
createdAt: new Date(1672531200), | ||
updatedAt: new Date(1672531200), | ||
refreshToken: null, | ||
|
@@ -147,7 +148,7 @@ describe('AuthService', () => { | |
firstName: 'First', | ||
lastName: 'Last', | ||
positionId: 'position-id', | ||
isAdmin: false, | ||
scope: EmployeeScope.BASE_USER, | ||
pswdHash: null, | ||
createdAt: new Date(0), | ||
updatedAt: new Date(0), | ||
|
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ import { EmployeesService } from './employees.service'; | |
import { PrismaService } from '../prisma/prisma.service'; | ||
import { EmployeeEntity } from './entities/employee.entity'; | ||
import { LoggerServiceImpl } from '../logger/logger.service'; | ||
import { EmployeeScope } from '@prisma/client'; | ||
|
||
describe('EmployeesController', () => { | ||
let controller: EmployeesController; | ||
|
@@ -47,7 +48,7 @@ describe('EmployeesController', () => { | |
}, | ||
}, | ||
email: '[email protected]', | ||
isAdmin: false, | ||
scope: EmployeeScope.BASE_USER, | ||
pswdHash: 'thisIsASecureHash', | ||
createdAt: new Date(1672531200), | ||
updatedAt: new Date(1672531200), | ||
|
@@ -74,7 +75,7 @@ describe('EmployeesController', () => { | |
}, | ||
}, | ||
email: '[email protected]', | ||
isAdmin: false, | ||
scope: EmployeeScope.BASE_USER, | ||
pswdHash: 'thisIsASecureHash', | ||
createdAt: new Date(1672531200), | ||
updatedAt: new Date(1672531200), | ||
|
@@ -104,7 +105,7 @@ describe('EmployeesController', () => { | |
}, | ||
}, | ||
email: '[email protected]', | ||
isAdmin: false, | ||
scope: EmployeeScope.BASE_USER, | ||
pswdHash: 'thisIsASecureHash', | ||
createdAt: new Date(1672531200), | ||
updatedAt: new Date(1672531200), | ||
|
@@ -131,7 +132,7 @@ describe('EmployeesController', () => { | |
}, | ||
}, | ||
email: '[email protected]', | ||
isAdmin: false, | ||
scope: EmployeeScope.BASE_USER, | ||
pswdHash: 'thisIsASecureHash', | ||
createdAt: new Date(1672531200), | ||
updatedAt: new Date(1672531200), | ||
|
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
Oops, something went wrong.