@@ -10,6 +10,9 @@ interface OAuthPluginOptions {
1010 emailField : string ;
1111 emailConfirmedField ?: string ;
1212 adapters : OAuth2Adapter [ ] ;
13+ iconOnly ?: boolean ;
14+ pill ?: boolean ;
15+ authenticationExpireDuration ?: number ;
1316 openSignup ?: {
1417 enabled ?: boolean ;
1518 defaultFieldValues ?: Record < string , any > ;
@@ -30,6 +33,8 @@ export default class OAuthPlugin extends AdminForthPlugin {
3033 // Set default values for openSignup
3134 this . options = {
3235 ...options ,
36+ iconOnly : options . iconOnly ?? false ,
37+ pill : options . pill ?? false ,
3338 openSignup : {
3439 enabled : options . openSignup ?. enabled ?? false ,
3540 defaultFieldValues : options . openSignup ?. defaultFieldValues ?? { } ,
@@ -43,11 +48,6 @@ export default class OAuthPlugin extends AdminForthPlugin {
4348 this . adminforth = adminforth ;
4449 this . resource = resource ;
4550
46- // Add custom page for OAuth callback
47- if ( ! adminforth . config . customization . customPages ) {
48- adminforth . config . customization . customPages = [ ] ;
49- }
50-
5151 adminforth . config . customization . customPages . push ( {
5252 path : '/oauth/callback' ,
5353 component : {
@@ -84,24 +84,30 @@ export default class OAuthPlugin extends AdminForthPlugin {
8484 }
8585
8686 // Register the component with the correct plugin path
87- const componentPath = `@@/plugins/${ this . constructor . name } /OAuthLoginButton .vue` ;
88- this . componentPath ( 'OAuthLoginButton .vue' ) ;
87+ const componentPath = `@@/plugins/${ this . constructor . name } /OAuthLoginButtons .vue` ;
88+ this . componentPath ( 'OAuthLoginButtons .vue' ) ;
8989
9090 const baseUrl = adminforth . config . baseUrl || '' ;
91- this . options . adapters . forEach ( adapter => {
91+ const providers = this . options . adapters . map ( adapter => {
9292 const state = Buffer . from ( JSON . stringify ( {
9393 provider : adapter . constructor . name
9494 } ) ) . toString ( 'base64' ) ;
9595
96- adminforth . config . customization . loginPageInjections . underInputs . push ( {
97- file : componentPath ,
98- meta : {
99- authUrl : `${ adapter . getAuthUrl ( ) } &state=${ state } ` ,
100- provider : adapter . constructor . name ,
101- baseUrl,
102- icon : adapter . getIcon ( )
103- }
104- } ) ;
96+ return {
97+ authUrl : `${ adapter . getAuthUrl ( ) } &state=${ state } ` ,
98+ provider : adapter . constructor . name ,
99+ baseUrl,
100+ icon : adapter . getIcon ( ) ,
101+ } ;
102+ } ) ;
103+
104+ adminforth . config . customization . loginPageInjections . underInputs . push ( {
105+ file : componentPath ,
106+ meta : {
107+ providers,
108+ iconOnly : this . options . iconOnly ,
109+ pill : this . options . pill ,
110+ }
105111 } ) ;
106112 }
107113
@@ -136,7 +142,7 @@ export default class OAuthPlugin extends AdminForthPlugin {
136142 response,
137143 username,
138144 pk : user . id ,
139- expireInDays : this . adminforth . config . auth . rememberMeDays
145+ expireInDays : this . options . authenticationExpireDuration ? this . options . authenticationExpireDuration : this . adminforth . config . auth . rememberMeDays
140146 } ) ;
141147 }
142148
0 commit comments