@@ -31,7 +31,7 @@ import { ActionCheckSource, AdminForthActionFront, AdminForthConfigMenuItem, Adm
3131 GetConfigResponse ,
3232 ShowInResolved } from "../types/Common.js" ;
3333import { filtersTools } from "../modules/filtersTools.js" ;
34- import is_ip_private from 'private-ip'
34+ import { normalizeColumnValue } from './columnValueNormalizer.js' ;
3535
3636
3737async function resolveBoolOrFn (
@@ -760,6 +760,8 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
760760 throw new Error ( 'No config.auth defined we need it to find user, please follow the docs' ) ;
761761 }
762762 const userResource = this . adminforth . config . resources . find ( ( res ) => res . resourceId === this . adminforth . config . auth . usersResourceId ) ;
763+ const usernameColumn = userResource . columns . find ( ( col ) => col . name === this . adminforth . config . auth . usernameField ) ;
764+ const normalizedUsername = normalizeColumnValue ( usernameColumn , username ) ;
763765 // if there is no passwordHashField, in columns, add it, with backendOnly and showIn: []
764766 if ( ! userResource . dataSourceColumns . find ( ( col ) => col . name === this . adminforth . config . auth . passwordHashField ) ) {
765767 userResource . dataSourceColumns . push ( {
@@ -775,7 +777,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
775777 await this . adminforth . connectors [ userResource . dataSource ] . getData ( {
776778 resource : userResource ,
777779 filters : { operator : AdminForthFilterOperators . AND , subFilters : [
778- { field : this . adminforth . config . auth . usernameField , operator : AdminForthFilterOperators . EQ , value : username } ,
780+ { field : this . adminforth . config . auth . usernameField , operator : AdminForthFilterOperators . EQ , value : normalizedUsername } ,
779781 ] } ,
780782 limit : 1 ,
781783 offset : 0 ,
@@ -795,7 +797,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
795797 adminUser = {
796798 dbUser : userRecord ,
797799 pk : userRecord [ userResource . columns . find ( ( col ) => col . primaryKey ) . name ] ,
798- username,
800+ username : normalizedUsername ,
799801 } ;
800802
801803 const expireInDuration = rememberMe
@@ -811,7 +813,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
811813 this . adminforth . auth . setAuthCookie ( {
812814 expireInDuration,
813815 response,
814- username,
816+ username : normalizedUsername ,
815817 pk : userRecord [ userResource . columns . find ( ( col ) => col . primaryKey ) . name ]
816818 } ) ;
817819 }
0 commit comments