Skip to content

Commit

Permalink
remove user verification #9
Browse files Browse the repository at this point in the history
allows admin to remove verification from a user
modifies the user schema to accept a verificationRemovedBy key with admin id as its value
updates the lambda function with a new case 'unverify'
  • Loading branch information
FarahZaqout committed Oct 14, 2019
1 parent c5ea6e8 commit faf63c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lambda/database/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ const schema = new mongoose.Schema({
type: Schema.Types.ObjectId,
ref: 'users',
},
verificationRemovedBy: {
type: Schema.Types.ObjectId,
ref: 'users',
},
});

const User = model('users', schema);
Expand Down
7 changes: 7 additions & 0 deletions src/lambda/database/queries/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ export const approveUser = (userId, adminId) =>
{ status: status.VERIFIED, verifiedBy: adminId },
{ new: true }
);

export const unverifyUser = (userId, adminId) =>
userId.findOneAndUpdate(
{ _id: userId },
{ status: status.UNVERIFIED, verificationRemovedBy: adminId },
{ new: true }
);
5 changes: 5 additions & 0 deletions src/lambda/manageUserStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
rejectSuperUser,
approveUser,
rejectUser,
unverifyUser,
} from './database/queries/user';
import { status } from '../constants/users';

Expand Down Expand Up @@ -60,6 +61,10 @@ async function manageUserStatus(event, context) {
msg = 'rejected user!';
}
break;
case 'unverify':
update = await unverifyUser(userId, admin);
msg = 'unverified user!';
break;

default:
update = null;
Expand Down

0 comments on commit faf63c1

Please sign in to comment.