Skip to content

Node.js based forum software built for the modern web

confirmEmail route

psychobunny942d16a3b4b2
diff --git a/src/controllers/index.js b/src/controllers/index.js
index 4f390d8085..fd7ba63ea6 100644
--- a/src/controllers/index.js
+++ b/src/controllers/index.js
@@ -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;
\ No newline at end of file
diff --git a/src/routes/api.js b/src/routes/api.js
index 0e6a9a6796..f64737cd81 100644
--- a/src/routes/api.js
+++ b/src/routes/api.js
@@ -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;
diff --git a/src/webserver.js b/src/webserver.js
index 7efde1418e..a0c6dd97fe 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -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);