Skip to content

Commit 7808969

Browse files
committed
feat(api): added greeting notification on account creation
1 parent fd7db66 commit 7808969

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/controllers/v4/internal/user.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import crypto from 'crypto';
22
import Users from '../../../models/schemas/User.js';
3+
import UserNotification from '../../../models/schemas/UserNotification.js';
34
import generateToken from '../../../modules/generateToken.js';
45

56
/**
@@ -241,8 +242,16 @@ const processUserSessionAndUpdate = async (req, res, next) => {
241242
access_token,
242243
password: crypto.randomBytes(22).toString('base64'), // Generate a random password
243244
};
245+
const newUserNotification = {
246+
_id: `U${(await UserNotification.countDocuments()) + 1}`,
247+
userId: id,
248+
type: 'success',
249+
message: `🎉 Welcome abroad!`,
250+
expiry: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
251+
};
244252

245253
await Users.create(newUser);
254+
await UserNotification.create(newUserNotification);
246255

247256
return res.status(201).json({
248257
message: 'User created successfully',

0 commit comments

Comments
 (0)