Conversation
There was a problem hiding this comment.
I was thinking that the roles, permissions and maby parts of the auth strategy can become it’s own package / plugin. That will give us a nice separation of concern, and allow other auth providers to use it and implement content API RBAC in Strapi. So it should have no dependency on Better Auth whatsoever. What do you think? @maccomaccomaccomacco
| const { ApplicationError, ValidationError } = errors; | ||
|
|
||
| export default ({ strapi }: { strapi: Core.Strapi }) => { | ||
| const roleService = () => |
There was a problem hiding this comment.
There is a way to add this return type automatically. I’ll add it to your branch.
| ctx.send({ data: { conditions: [], sections: layout } }); | ||
| }, | ||
|
|
||
| async createRole(ctx: { request: { body: unknown }; send: (body: unknown) => void }) { |
There was a problem hiding this comment.
These crud actions could probably be a factory controller
| routes: [ | ||
| { | ||
| method: "POST", | ||
| path: "/better-auth/invite/set-password", |
There was a problem hiding this comment.
I’m wondering how much of this invite flow can be ‘native’ better auth. For example setting a password is a very common action.
| const apiEntry = actionsMap[apiKey]; | ||
| const controllerActions = apiEntry?.controllers?.[controllerName] ?? []; | ||
|
|
||
| const allowedActions = isSingle |
There was a problem hiding this comment.
Does this mean custom controller actions are filtered out?
|
|
||
| const userEmail = (user as { email: string }).email; | ||
|
|
||
| await strapi.documents(ACCOUNT_UID).create({ |
There was a problem hiding this comment.
I think we should try to refrain from using the Document Service to interact with Better Auth data. I believe everything should be possible through their API.
| name: "better-auth", | ||
| authenticate: async (ctx: ParameterizedContext): Promise<AuthResult> => { | ||
| try { | ||
| const authConfig = (strapi as unknown as { internal_config: Record<string, unknown> }).internal_config["better-auth"] as |
There was a problem hiding this comment.
There is a type provided by Better Auth for this. I believe they call it ‘Auth’. I’m wondering if we can globally set this type so that people using the plugin get that type automatically. Just like the ‘strapi’ global.
| * If config["better-auth"] is a function (strapi) => authInstance, call it with strapi | ||
| * and store the result. This allows the project config to use strapi for sendResetPassword etc. | ||
| */ | ||
| function ensureBetterAuthInitialized(strapi: Core.Strapi) { |
There was a problem hiding this comment.
Why is this needed? Shouldn’t we just throw an error when no config was found?
No description provided.