Skip to content

Commit 00ee4ff

Browse files
committed
dev-demo: add email-invite plugin
AdminForth/1777/image
1 parent c81c0a6 commit 00ee4ff

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

dev-demo/resources/adminuser.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@ import UserSoftDelete from '../../plugins/adminforth-user-soft-delete/index.js';
1111
import KeyValueAdapterRam from '../../adapters/adminforth-key-value-adapter-ram/index.js';
1212
import OAuthPlugin from './configs/oauthPluginConfig.js';
1313
import EmailInvitePlugin from '../../plugins/adminforth-email-invite/index.js';
14+
import EmailPasswordResetPlugin from '../../plugins/adminforth-email-password-reset/index.js';
1415

1516
async function allowedForSuperAdmin({ adminUser }: { adminUser: AdminUser }): Promise<boolean> {
1617
return adminUser.dbUser.role === 'superadmin';
1718
}
1819

20+
const fakeEmailAdapter = {
21+
validate: async () => {
22+
// Implement validation logic if needed
23+
},
24+
sendEmail: async (from: string, to: string, text: string, html: string, subject: string) => {
25+
console.log('Sending email with html:', html);
26+
console.log('Sending email with text:', text);
27+
return { ok: true };
28+
}
29+
};
30+
1931
export default {
2032
dataSource: 'sqlite',
2133
table: 'adminuser',
@@ -210,17 +222,16 @@ export default {
210222
emailField: 'email',
211223
sendFrom: 'noreply@yourapp.com',
212224
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-
},
225+
adapter: fakeEmailAdapter,
222226
emailConfirmedField: 'email_confirmed', // Enable email confirmation
223227
}),
228+
new EmailPasswordResetPlugin({
229+
emailField: 'email',
230+
passwordField: 'password',
231+
sendFrom: 'no-reply@devforth.io',
232+
adapter: fakeEmailAdapter,
233+
userResetTokensKeyValueAdapter: new KeyValueAdapterRam(),
234+
}),
224235
],
225236
hooks: {
226237
create: {

0 commit comments

Comments
 (0)