-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53c3b2c
commit cb31e75
Showing
2 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import models from '../db/models'; | ||
import sender from '../services/email'; | ||
|
||
/** | ||
* This class creates the user controller | ||
*/ | ||
export default class UserController { | ||
/** | ||
* @param {object} req The user's signup details | ||
* @param {object} res The user's details returned after signup | ||
* @returns {object} A signed up user | ||
*/ | ||
static async rejectRequest(req, res) { | ||
try { | ||
const user = await models.Request.update( | ||
{ | ||
role: 'rejected' | ||
}, | ||
{ | ||
where: { | ||
id: req.params.id | ||
} | ||
} | ||
); | ||
|
||
// parameter(s) to be passed to the sendgrid email template | ||
const payload = { user }; | ||
await sender.sendEmail(process.env.SENDER_EMAIL, user.email, 'signup_template', payload); | ||
return res.status(201).json({ | ||
status: 'success', | ||
data: {} | ||
}); | ||
} catch (error) { | ||
return res.status(500) | ||
.json({ | ||
status: 'error', | ||
error: 'Error accessing request route', | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters