Skip to content

Commit

Permalink
Resolve rebase conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle1morel committed Sep 4, 2024
1 parent c4847ca commit 6dae104
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions app/src/interfaces/IExpress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import * as core from 'express-serve-static-core';
import type { CurrentAuthorization } from '../types/CurrentAuthorization';
import type { CurrentContext } from '../types/CurrentContext';

declare module 'express-serve-static-core' {
export interface Request {
currentAuthorization: CurrentAuthorization;
currentContext: CurrentContext;
}
}

interface Query extends core.Query {}

interface Params extends core.ParamsDictionary {}

export interface Request<P extends Params = never, Q extends Query = never, B = never> extends core.Request {
currentAuthorization?: CurrentAuthorization;
currentContext?: CurrentContext;
params: P;
query: Q;
body: B;
Expand Down
1 change: 1 addition & 0 deletions app/src/middleware/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const currentContext = (initiative: Initiative) => {
}

if (isValid) {
currentContext.bearerToken = bearerToken;
currentContext.tokenPayload = isValid as jwt.JwtPayload;
const user = await userService.login(currentContext.tokenPayload);

Expand Down
2 changes: 1 addition & 1 deletion app/src/middleware/requireSomeGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const requireSomeGroup = async (req: Request, _res: Response, next: NextF

// Auto assign all PROPONENT groups if user has none
if (groups && groups.length === 0) {
await yarsService.assignGroup(sub, Initiative.HOUSING, GroupName.PROPONENT);
await yarsService.assignGroup(req.currentContext.bearerToken, sub, Initiative.HOUSING, GroupName.PROPONENT);
groups = await yarsService.getSubjectGroups(sub);
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/services/yars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const service = {
* @function assignGroup
* Assigns an identity to the given group
* Assigns permissions to COMS based on the given group
* @param {string | null | undefined} bearerToken The bearer token of the authorized user
* @param {string | undefined} bearerToken The bearer token of the authorized user
* @param {string} identityId Identity ID of the authorized user
* @param {Initiative} initiative The initiative to associate with the group
* @param {GroupName} group The group to add the user to
* @returns {Promise<{identityId: string;roleId: number;}>} The result of running the create operation
*/
assignGroup: async (sub: string, initiative: Initiative, group: GroupName) => {
assignGroup: async (bearerToken: string | undefined, sub: string, initiative: Initiative, group: GroupName) => {
try {
const i = await prisma.initiative.findFirstOrThrow({
where: {
Expand Down
2 changes: 1 addition & 1 deletion app/src/types/CurrentContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { AuthType, Initiative } from '../utils/enums/application';

export type CurrentContext = {
authType?: AuthType;
bearerToken?: string;
initiative?: Initiative;
tokenPayload?: jwt.JwtPayload;
bearerToken: string | null;
userId?: string;
};

0 comments on commit 6dae104

Please sign in to comment.