@@ -10,6 +10,7 @@ import DashboardPlugin from '../../plugins/adminforth-dashboard/index.js';
1010import UserSoftDelete from '../../plugins/adminforth-user-soft-delete/index.js' ;
1111import KeyValueAdapterRam from '../../adapters/adminforth-key-value-adapter-ram/index.js' ;
1212import OAuthPlugin from './configs/oauthPluginConfig.js' ;
13+ import EmailInvitePlugin from '../../plugins/adminforth-email-invite/index.js' ;
1314
1415async function allowedForSuperAdmin ( { adminUser } : { adminUser : AdminUser } ) : Promise < boolean > {
1516 return adminUser . dbUser . role === 'superadmin' ;
@@ -68,9 +69,7 @@ export default {
6869 editingNote : { edit : 'Leave empty to keep password unchanged' } ,
6970 type : AdminForthDataTypes . STRING ,
7071 showIn : { // to show field only on create and edit pages
71- show : false ,
72- list : false ,
73- filter : false ,
72+ all : false ,
7473 } ,
7574 masked : true , // to show stars in input field
7675
@@ -115,6 +114,10 @@ export default {
115114 edit : true ,
116115 } ,
117116 } ,
117+ {
118+ name : 'email_confirmed' ,
119+ type : AdminForthDataTypes . BOOLEAN
120+ } ,
118121 ] ,
119122 plugins : [
120123 new TwoFactorsAuthPlugin (
@@ -203,11 +206,28 @@ export default {
203206 return false ;
204207 }
205208 } ) ,
209+ new EmailInvitePlugin ( {
210+ emailField : 'email' ,
211+ sendFrom : 'noreply@yourapp.com' ,
212+ passwordField : 'password' ,
213+ adapter : {
214+ validate : async ( ) => {
215+
216+ } ,
217+ sendEmail : async ( from , to , text , html , subject ) => {
218+ console . log ( 'Sending email with html:' , html ) ;
219+ return { ok : true } ;
220+ }
221+ } ,
222+ emailConfirmedField : 'email_confirmed' , // Enable email confirmation
223+ } ) ,
206224 ] ,
207225 hooks : {
208226 create : {
209227 beforeSave : async ( { record, adminUser, resource } : { record : any , adminUser : AdminUser , resource : AdminForthResource } ) => {
210- record . password_hash = await AdminForth . Utils . generatePasswordHash ( record . password ) ;
228+ if ( record . password ) {
229+ record . password_hash = await AdminForth . Utils . generatePasswordHash ( record . password ) ;
230+ }
211231 return { ok : true } ;
212232 }
213233 } ,
0 commit comments