|
@@ -1,4 +1,8 @@
|
|
|
|
|
+const logger = require('@alias/logger')('growi:routes:forgot-password');
|
|
|
|
|
+const ApiResponse = require('../util/apiResponse');
|
|
|
|
|
+
|
|
|
module.exports = function(crowi, app) {
|
|
module.exports = function(crowi, app) {
|
|
|
|
|
+ const PasswordResetOrder = crowi.model('PasswordResetOrder');
|
|
|
const { /* appService, */ mailService, configManager } = crowi;
|
|
const { /* appService, */ mailService, configManager } = crowi;
|
|
|
const path = require('path');
|
|
const path = require('path');
|
|
|
const actions = {};
|
|
const actions = {};
|
|
@@ -17,7 +21,7 @@ module.exports = function(crowi, app) {
|
|
|
async function sendPasswordResetEmail(i18n) {
|
|
async function sendPasswordResetEmail(i18n) {
|
|
|
|
|
|
|
|
return mailService.send({
|
|
return mailService.send({
|
|
|
- to: 'hoge@gmail.com',
|
|
|
|
|
|
|
+ to: 'hoge@example.com',
|
|
|
subject: 'forgotPasswordMailTest',
|
|
subject: 'forgotPasswordMailTest',
|
|
|
template: path.join(crowi.localeDir, `${i18n}/notifications/passwordReset.txt`),
|
|
template: path.join(crowi.localeDir, `${i18n}/notifications/passwordReset.txt`),
|
|
|
// TODO: need to set appropriate values by GW-6828
|
|
// TODO: need to set appropriate values by GW-6828
|
|
@@ -30,6 +34,18 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
api.post = async function(req, res) {
|
|
api.post = async function(req, res) {
|
|
|
|
|
+ // TODO: using email getting by password reset request form by GW-6828
|
|
|
|
|
+ const email = 'foo@example.com';
|
|
|
|
|
+ try {
|
|
|
|
|
+ const passwordResetOrderData = await PasswordResetOrder.createPasswordResetOrder(email);
|
|
|
|
|
+ res.send(ApiResponse.success({ passwordResetOrderData }));
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ const msg = 'Error occurred during password reset request procedure';
|
|
|
|
|
+ logger.error(err);
|
|
|
|
|
+ return res.json(ApiResponse.error(msg));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const grobalLang = configManager.getConfig('crowi', 'app:globalLang');
|
|
const grobalLang = configManager.getConfig('crowi', 'app:globalLang');
|
|
|
const i18n = req.language || grobalLang;
|
|
const i18n = req.language || grobalLang;
|
|
|
|
|
|