Visitar URL original
fix(generators): use entity camelName for auth params in schema templ… · feathersjs/feathers@05bb6c8 · GitHub
Skip to content

Commit 05bb6c8

Browse files
fix(generators): use entity camelName for auth params in schema templates (#3706)
1 parent 4b042aa commit 05bb6c8

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎packages/generators/src/service/templates/schema.json.tpl.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext<
115115
? `
116116
// If there is a user (e.g. with authentication), they are only allowed to see their own data
117117
${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
118-
if (context.params.user) {
119-
return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
118+
if (context.params.${camelName}) {
119+
return context.params.${camelName}.${type === 'mongodb' ? '_id' : 'id'}
120120
}
121121
122122
return value

‎packages/generators/src/service/templates/schema.typebox.tpl.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ export const ${camelName}QueryResolver = resolve<${upperName}Query, HookContext<
103103
? `
104104
// If there is a user (e.g. with authentication), they are only allowed to see their own data
105105
${type === 'mongodb' ? '_id' : 'id'}: async (value, user, context) => {
106-
if (context.params.user) {
107-
return context.params.user.${type === 'mongodb' ? '_id' : 'id'}
106+
if (context.params.${camelName}) {
107+
return context.params.${camelName}.${type === 'mongodb' ? '_id' : 'id'}
108108
}
109109
110110
return value

0 commit comments

Comments
 (0)