Skip to content

Commit

Permalink
set userid and email based on presence of service token/jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
maidul98 committed Jan 16, 2023
1 parent 35f4d27 commit da3742f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions backend/src/controllers/v2/secretsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,16 @@ export const getSecrets = async (req: Request, res: Response) => {
}]
#swagger.parameters['workspaceId'] = {
"description": "ID of project",
"required": true,
"type": "string"
}
"description": "ID of project",
"required": true,
"type": "string"
}
#swagger.parameters['environment'] = {
"description": "Environment within project",
"required": true,
"type": "string"
}
"description": "Environment within project",
"required": true,
"type": "string"
}
#swagger.responses[200] = {
content: {
Expand All @@ -254,8 +254,8 @@ export const getSecrets = async (req: Request, res: Response) => {
*/
const { workspaceId, environment } = req.query;

let userId: Types.ObjectId | undefined = undefined // used for getting personal secrets for user
let userEmail: Types.ObjectId | undefined = undefined // used for posthog
let userId = "" // used for getting personal secrets for user
let userEmail = "" // used for posthog
if (req.user) {
userId = req.user._id;
userEmail = req.user.email;
Expand Down Expand Up @@ -284,13 +284,13 @@ export const getSecrets = async (req: Request, res: Response) => {

const readAction = await EELogService.createActionSecret({
name: ACTION_READ_SECRETS,
userId: req.user._id.toString(),
userId: userId,
workspaceId: workspaceId as string,
secretIds: secrets.map((n: any) => n._id)
});

readAction && await EELogService.createLog({
userId: req.user._id.toString(),
userId: userId,
workspaceId: workspaceId as string,
actions: [readAction],
channel,
Expand Down

0 comments on commit da3742f

Please sign in to comment.