@@ -10,6 +10,9 @@ interface OAuthPluginOptions {
10
10
emailField : string ;
11
11
emailConfirmedField ?: string ;
12
12
adapters : OAuth2Adapter [ ] ;
13
+ iconOnly ?: boolean ;
14
+ pill ?: boolean ;
15
+ authenticationExpireDuration ?: number ;
13
16
openSignup ?: {
14
17
enabled ?: boolean ;
15
18
defaultFieldValues ?: Record < string , any > ;
@@ -30,6 +33,8 @@ export default class OAuthPlugin extends AdminForthPlugin {
30
33
// Set default values for openSignup
31
34
this . options = {
32
35
...options ,
36
+ iconOnly : options . iconOnly ?? false ,
37
+ pill : options . pill ?? false ,
33
38
openSignup : {
34
39
enabled : options . openSignup ?. enabled ?? false ,
35
40
defaultFieldValues : options . openSignup ?. defaultFieldValues ?? { } ,
@@ -43,11 +48,6 @@ export default class OAuthPlugin extends AdminForthPlugin {
43
48
this . adminforth = adminforth ;
44
49
this . resource = resource ;
45
50
46
- // Add custom page for OAuth callback
47
- if ( ! adminforth . config . customization . customPages ) {
48
- adminforth . config . customization . customPages = [ ] ;
49
- }
50
-
51
51
adminforth . config . customization . customPages . push ( {
52
52
path : '/oauth/callback' ,
53
53
component : {
@@ -84,24 +84,30 @@ export default class OAuthPlugin extends AdminForthPlugin {
84
84
}
85
85
86
86
// 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' ) ;
89
89
90
90
const baseUrl = adminforth . config . baseUrl || '' ;
91
- this . options . adapters . forEach ( adapter => {
91
+ const providers = this . options . adapters . map ( adapter => {
92
92
const state = Buffer . from ( JSON . stringify ( {
93
93
provider : adapter . constructor . name
94
94
} ) ) . toString ( 'base64' ) ;
95
95
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
+ }
105
111
} ) ;
106
112
}
107
113
@@ -136,7 +142,7 @@ export default class OAuthPlugin extends AdminForthPlugin {
136
142
response,
137
143
username,
138
144
pk : user . id ,
139
- expireInDays : this . adminforth . config . auth . rememberMeDays
145
+ expireInDays : this . options . authenticationExpireDuration ? this . options . authenticationExpireDuration : this . adminforth . config . auth . rememberMeDays
140
146
} ) ;
141
147
}
142
148
0 commit comments