mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 10:06:13 +01:00
confirmEmail route
This commit is contained in:
@@ -78,7 +78,7 @@ Controllers.home = function(req, res, next) {
|
||||
};
|
||||
|
||||
|
||||
Controllers.login = function (req, res, next) {
|
||||
Controllers.login = function(req, res, next) {
|
||||
var data = {},
|
||||
login_strategies = auth.get_login_strategies(),
|
||||
num_strategies = login_strategies.length,
|
||||
@@ -107,7 +107,7 @@ Controllers.login = function (req, res, next) {
|
||||
}
|
||||
};
|
||||
|
||||
Controllers.register = function (req, res, next) {
|
||||
Controllers.register = function(req, res, next) {
|
||||
var data = {},
|
||||
login_strategies = auth.get_login_strategies(),
|
||||
num_strategies = login_strategies.length;
|
||||
@@ -140,5 +140,28 @@ Controllers.register = function (req, res, next) {
|
||||
};
|
||||
|
||||
|
||||
Controllers.confirmEmail = function(req, res, next) {
|
||||
user.email.confirm(req.params.code, function (data) {
|
||||
if (data.status === 'ok') {
|
||||
data = {
|
||||
'alert-class': 'alert-success',
|
||||
title: 'Email Confirmed',
|
||||
text: 'Thank you for vaidating your email. Your account is now fully activated.'
|
||||
};
|
||||
} else {
|
||||
data = {
|
||||
'alert-class': 'alert-danger',
|
||||
title: 'An error occurred...',
|
||||
text: 'There was a problem validating your email address. Perhaps the code was invalid or has expired.'
|
||||
};
|
||||
}
|
||||
|
||||
if (res.locals.isAPI) {
|
||||
res.json(data);
|
||||
} else {
|
||||
res.render('confirm', data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = Controllers;
|
||||
@@ -202,24 +202,6 @@ var path = require('path'),
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/confirm/:id', function (req, res) {
|
||||
user.email.confirm(req.params.id, function (data) {
|
||||
if (data.status === 'ok') {
|
||||
res.json({
|
||||
'alert-class': 'alert-success',
|
||||
title: 'Email Confirmed',
|
||||
text: 'Thank you for vaidating your email. Your account is now fully activated.'
|
||||
});
|
||||
} else {
|
||||
res.json({
|
||||
'alert-class': 'alert-danger',
|
||||
title: 'An error occurred...',
|
||||
text: 'There was a problem validating your email address. Perhaps the code was invalid or has expired.'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.get('/outgoing', function (req, res) {
|
||||
var url = req.query.url;
|
||||
|
||||
|
||||
@@ -616,7 +616,7 @@ process.on('uncaughtException', function(err) {
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
/* Main */
|
||||
app.get('/', app.buildHeader, controllers.home);
|
||||
app.get('/api/home', app.prepareAPI, controllers.home);
|
||||
|
||||
@@ -626,9 +626,14 @@ process.on('uncaughtException', function(err) {
|
||||
app.get('/register', app.buildHeader, controllers.register);
|
||||
app.get('/api/register', app.prepareAPI, controllers.register);
|
||||
|
||||
app.get('/confirm/:code', app.buildHeader, controllers.confirmEmail);
|
||||
app.get('/api/confirm/:code', app.prepareAPI, controllers.confirmEmail);
|
||||
|
||||
/* Topics */
|
||||
app.get('/topic/:topic_id/:slug?', app.buildHeader, controllers.topics.get);
|
||||
app.get('/api/topic/:topic_id/:slug?', app.prepareAPI, controllers.topics.get);
|
||||
|
||||
/* Categories */
|
||||
app.get('/popular/:set?', app.buildHeader, controllers.categories.popular);
|
||||
app.get('/api/popular/:set?', app.prepareAPI, controllers.categories.popular);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user