|
1 | | -import { AdminForthPlugin, parseBody, AdminForthDataTypes, AdminForthResourcePages, Filters} from "adminforth"; |
| 1 | +import { AdminForthPlugin, AdminForthDataTypes, AdminForthResourcePages, Filters} from "adminforth"; |
2 | 2 | import type { IAdminForth, IHttpServer, AdminForthResourceColumn, AdminForthResource, IAdminForthHttpResponse, AdminUser, AdminForthComponentDeclaration } from "adminforth"; |
3 | 3 | import type { PluginOptions } from './types.js'; |
4 | 4 | import { error } from "console"; |
@@ -113,12 +113,10 @@ export default class UserSoftDelete extends AdminForthPlugin { |
113 | 113 | server.endpoint({ |
114 | 114 | method: 'POST', |
115 | 115 | path: `/plugin/${this.pluginInstanceId}/deactivateUser`, |
| 116 | + request_schema: deactivateUserBodySchema, |
116 | 117 | handler: async ({ adminUser, body, response }) => { |
117 | 118 | console.log(`UserSoftDelete: deactivateUser endpoint called by ${adminUser.dbUser[this.resourceConfig.columns.find((col) => col.primaryKey).name]}`); |
118 | | - const parsed = parseBody(deactivateUserBodySchema, body, response); |
119 | | - console.log(`UserSoftDelete: parsed body: ${JSON.stringify(parsed)}`); |
120 | | - if ('error' in parsed) return parsed.error; |
121 | | - const data = parsed.data; |
| 119 | + const data = body as z.infer<typeof deactivateUserBodySchema>; |
122 | 120 | let isAllowedToDeactivate = false; |
123 | 121 | if ( typeof this.allowDisableFunc === "function" ) { |
124 | 122 | isAllowedToDeactivate = await this.allowDisableFunc(adminUser); |
|
0 commit comments