File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed
Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change 11import joi from 'joi' ;
22import { componentSchema } from '../../utilities/componentSchema' ;
33
4+ const strategyBaseSchema = joi . object ( ) . keys ( {
5+ refresh : joi . boolean ( ) ,
6+ logout : joi . boolean ( ) ,
7+ } ) ;
8+
49const collectionSchema = joi . object ( ) . keys ( {
510 slug : joi . string ( ) . required ( ) ,
611 labels : joi . object ( {
@@ -88,15 +93,18 @@ const collectionSchema = joi.object().keys({
8893 } ) ,
8994 maxLoginAttempts : joi . number ( ) ,
9095 disableLocalStrategy : joi . boolean ( ) . valid ( true ) ,
91- strategies : joi . array ( ) . items ( joi . object ( ) . keys ( {
92- name : joi . string ( ) ,
93- strategy : joi . alternatives ( ) . try (
94- joi . func ( ) . maxArity ( 1 ) . required ( ) ,
95- joi . object ( )
96- ) ,
97- refresh : joi . boolean ( ) ,
98- logout : joi . boolean ( ) ,
99- } ) ) ,
96+ strategies : joi . array ( ) . items ( joi . alternatives ( ) . try (
97+ strategyBaseSchema . keys ( {
98+ name : joi . string ( ) . required ( ) ,
99+ strategy : joi . func ( )
100+ . maxArity ( 1 )
101+ . required ( ) ,
102+ } ) ,
103+ strategyBaseSchema . keys ( {
104+ name : joi . string ( ) ,
105+ strategy : joi . object ( ) . required ( ) ,
106+ } ) ,
107+ ) ) ,
100108 } ) ,
101109 joi . boolean ( ) ,
102110 ) ,
Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ export default (config: SanitizedConfig): PayloadAuthenticate => {
1212 const collectionMethods = [ ...enabledMethods ] ;
1313
1414 if ( Array . isArray ( collection . auth . strategies ) ) {
15- collection . auth . strategies . forEach ( ( { name } , index ) => {
16- collectionMethods . unshift ( `${ collection . slug } -${ name ?? index } ` ) ;
15+ collection . auth . strategies . forEach ( ( { name, strategy } ) => {
16+ collectionMethods . unshift ( `${ collection . slug } -${ name ?? strategy . name } ` ) ;
1717 } ) ;
1818 }
1919
You can’t perform that action at this time.
0 commit comments