@@ -4,22 +4,23 @@ import { IHttpServer } from "adminforth";
44import { randomUUID } from 'crypto' ;
55import type { OAuth2Adapter } from "adminforth" ;
66import { AdminForthDataTypes } from "adminforth" ;
7+ import type { HttpExtra } from './types.js' ;
78
8- interface OAuth2SSOPluginOptions {
9+ interface OAuthPluginOptions {
910 emailField : string ;
1011 emailConfirmedField ?: string ;
1112 adapters : OAuth2Adapter [ ] ;
1213}
1314
14- export class OAuth2SSOPlugin extends AdminForthPlugin {
15- private options : OAuth2SSOPluginOptions ;
16- private adminforth : IAdminForth ;
15+ export class OAuthPlugin extends AdminForthPlugin {
16+ private options : OAuthPluginOptions ;
17+ public adminforth : IAdminForth ;
1718 private resource : AdminForthResource ;
1819
19- constructor ( options : OAuth2SSOPluginOptions ) {
20+ constructor ( options : OAuthPluginOptions ) {
2021 super ( options , import . meta. url ) ;
2122 if ( ! options . emailField ) {
22- throw new Error ( 'OAuth2SSOPlugin : emailField is required' ) ;
23+ throw new Error ( 'OAuthPlugin : emailField is required' ) ;
2324 }
2425 this . options = options ;
2526 }
@@ -32,26 +33,26 @@ export class OAuth2SSOPlugin extends AdminForthPlugin {
3233
3334 // Validate emailField exists in resource
3435 if ( ! resource . columns . find ( col => col . name === this . options . emailField ) ) {
35- throw new Error ( `OAuth2SSOPlugin : emailField "${ this . options . emailField } " not found in resource columns` ) ;
36+ throw new Error ( `OAuthPlugin : emailField "${ this . options . emailField } " not found in resource columns` ) ;
3637 }
3738
3839 // Validate emailConfirmedField if provided
3940 if ( this . options . emailConfirmedField ) {
4041 const confirmedField = resource . columns . find ( col => col . name === this . options . emailConfirmedField ) ;
4142 if ( ! confirmedField ) {
42- throw new Error ( `OAuth2SSOPlugin : emailConfirmedField "${ this . options . emailConfirmedField } " not found in resource columns` ) ;
43+ throw new Error ( `OAuthPlugin : emailConfirmedField "${ this . options . emailConfirmedField } " not found in resource columns` ) ;
4344 }
4445 if ( confirmedField . type !== AdminForthDataTypes . BOOLEAN ) {
45- throw new Error ( `OAuth2SSOPlugin : emailConfirmedField "${ this . options . emailConfirmedField } " must be a boolean field` ) ;
46+ throw new Error ( `OAuthPlugin : emailConfirmedField "${ this . options . emailConfirmedField } " must be a boolean field` ) ;
4647 }
4748 }
4849
4950 // Make sure customization and loginPageInjections exist
50- if ( ! adminforth . config . customization ) {
51- adminforth . config . customization = { } ;
52- }
53- if ( ! adminforth . config . customization . loginPageInjections ) {
54- adminforth . config . customization . loginPageInjections = { underInputs : [ ] } ;
51+ if ( ! adminforth . config . customization ?. loginPageInjections ) {
52+ adminforth . config . customization = {
53+ ... adminforth . config . customization ,
54+ loginPageInjections : { underInputs : [ ] }
55+ } ;
5556 }
5657
5758 // Register the component with the correct plugin path
0 commit comments