mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 16:27:40 +00:00
set userid and email based on presence of service token/jwt
This commit is contained in:
@@ -222,16 +222,16 @@ export const getSecrets = async (req: Request, res: Response) => {
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
#swagger.parameters['workspaceId'] = {
|
#swagger.parameters['workspaceId'] = {
|
||||||
"description": "ID of project",
|
"description": "ID of project",
|
||||||
"required": true,
|
"required": true,
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
|
||||||
#swagger.parameters['environment'] = {
|
#swagger.parameters['environment'] = {
|
||||||
"description": "Environment within project",
|
"description": "Environment within project",
|
||||||
"required": true,
|
"required": true,
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
|
|
||||||
#swagger.responses[200] = {
|
#swagger.responses[200] = {
|
||||||
content: {
|
content: {
|
||||||
@@ -254,8 +254,8 @@ export const getSecrets = async (req: Request, res: Response) => {
|
|||||||
*/
|
*/
|
||||||
const { workspaceId, environment } = req.query;
|
const { workspaceId, environment } = req.query;
|
||||||
|
|
||||||
let userId: Types.ObjectId | undefined = undefined // used for getting personal secrets for user
|
let userId = "" // used for getting personal secrets for user
|
||||||
let userEmail: Types.ObjectId | undefined = undefined // used for posthog
|
let userEmail = "" // used for posthog
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
userId = req.user._id;
|
userId = req.user._id;
|
||||||
userEmail = req.user.email;
|
userEmail = req.user.email;
|
||||||
@@ -284,13 +284,13 @@ export const getSecrets = async (req: Request, res: Response) => {
|
|||||||
|
|
||||||
const readAction = await EELogService.createActionSecret({
|
const readAction = await EELogService.createActionSecret({
|
||||||
name: ACTION_READ_SECRETS,
|
name: ACTION_READ_SECRETS,
|
||||||
userId: req.user._id.toString(),
|
userId: userId,
|
||||||
workspaceId: workspaceId as string,
|
workspaceId: workspaceId as string,
|
||||||
secretIds: secrets.map((n: any) => n._id)
|
secretIds: secrets.map((n: any) => n._id)
|
||||||
});
|
});
|
||||||
|
|
||||||
readAction && await EELogService.createLog({
|
readAction && await EELogService.createLog({
|
||||||
userId: req.user._id.toString(),
|
userId: userId,
|
||||||
workspaceId: workspaceId as string,
|
workspaceId: workspaceId as string,
|
||||||
actions: [readAction],
|
actions: [readAction],
|
||||||
channel,
|
channel,
|
||||||
|
|||||||
Reference in New Issue
Block a user