File tree Expand file tree Collapse file tree 4 files changed +12
-4
lines changed
Expand file tree Collapse file tree 4 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export interface ObjectQLAdapterConfig {
2828export function createObjectQLAdapter ( config : ObjectQLAdapterConfig ) {
2929 const { ql, debugLogs = false } = config ;
3030
31- return ( options : BetterAuthOptions ) => {
31+ return ( _options : BetterAuthOptions ) => {
3232 // Model name mapping (better-auth uses lowercase model names)
3333 const modelMap : Record < string , string > = {
3434 user : 'User' ,
Original file line number Diff line number Diff line change @@ -85,8 +85,13 @@ export type ObjectStackClientSession = {
8585export function usePermissions ( ) {
8686 const { data : session , isPending } = useSession ( ) ;
8787
88+ // Safely extract permissions, defaulting to undefined if not present
89+ const permissions = session ?. user && 'permissions' in session . user
90+ ? ( session . user as any ) . permissions
91+ : undefined ;
92+
8893 return {
89- permissions : ( session ?. user as any ) ?. permissions as string [ ] | Record < string , boolean > | null | undefined ,
94+ permissions,
9095 isPending,
9196 isAuthenticated : ! ! session ,
9297 } ;
Original file line number Diff line number Diff line change @@ -101,7 +101,10 @@ export function createAuthPlugin(config: AuthPluginConfig = {}): ObjectStackPlug
101101 // Better-Auth exposes a handler for all auth routes
102102 // The handler expects a Web Request object
103103 context . app . all ( '/api/auth/*' , async ( req : any ) => {
104- return authServer ! . handler ( req ) ;
104+ if ( ! authServer ) {
105+ throw new Error ( 'Auth server not initialized' ) ;
106+ }
107+ return authServer . handler ( req ) ;
105108 } ) ;
106109
107110 console . log ( '[Auth Plugin] Authentication routes registered at /api/auth/*' ) ;
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ export function createAuthServer(config: ObjectStackAuthServerConfig) {
8484 }
8585
8686 // Add social providers if configured
87- if ( socialProviders && typeof socialProviders === 'object' && Object . keys ( socialProviders ) . length > 0 ) {
87+ if ( socialProviders && Object . keys ( socialProviders ) . length > 0 ) {
8888 authOptions . socialProviders = socialProviders as BetterAuthOptions [ 'socialProviders' ] ;
8989 }
9090
You can’t perform that action at this time.
0 commit comments