Updated jsdoc comments
This commit is contained in:
@ -5,6 +5,7 @@ var sendgrid = require('sendgrid')(secrets.sendgrid.user, secrets.sendgrid.pass
|
|||||||
* GET /contact
|
* GET /contact
|
||||||
* Contact form page.
|
* Contact form page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.getContact = function(req, res) {
|
exports.getContact = function(req, res) {
|
||||||
res.render('contact', {
|
res.render('contact', {
|
||||||
title: 'Contact',
|
title: 'Contact',
|
||||||
@ -25,11 +26,11 @@ exports.postContact = function(req, res) {
|
|||||||
var from = req.body.email;
|
var from = req.body.email;
|
||||||
var name = req.body.name;
|
var name = req.body.name;
|
||||||
var body = req.body.message;
|
var body = req.body.message;
|
||||||
var sendTo = 'sahat@me.com';
|
var to = 'sahat@me.com';
|
||||||
var subject = 'API Example | Contact Form';
|
var subject = 'API Example | Contact Form';
|
||||||
|
|
||||||
var email = new sendgrid.Email({
|
var email = new sendgrid.Email({
|
||||||
to: sendTo,
|
to: to,
|
||||||
from: from,
|
from: from,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
text: body + '\n\n' + name
|
text: body + '\n\n' + name
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
* GET /
|
* GET /
|
||||||
* Home page.
|
* Home page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.index = function(req, res) {
|
exports.index = function(req, res) {
|
||||||
res.render('home', {
|
res.render('home', {
|
||||||
title: 'Home'
|
title: 'Home'
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
/**
|
|
||||||
* Module dependencies.
|
|
||||||
*/
|
|
||||||
var mongoose = require('mongoose');
|
var mongoose = require('mongoose');
|
||||||
var passport = require('passport');
|
var passport = require('passport');
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
|
|
||||||
/**
|
|
||||||
* Models.
|
|
||||||
*/
|
|
||||||
var User = require('../models/User');
|
var User = require('../models/User');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /login
|
* GET /login
|
||||||
* Login page.
|
* Login page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.getLogin = function(req, res) {
|
exports.getLogin = function(req, res) {
|
||||||
if (req.user) return res.redirect('/');
|
if (req.user) return res.redirect('/');
|
||||||
res.render('account/login', {
|
res.render('account/login', {
|
||||||
@ -26,6 +20,7 @@ exports.getLogin = function(req, res) {
|
|||||||
* GET /signup
|
* GET /signup
|
||||||
* Signup page.
|
* Signup page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.getSignup = function(req, res) {
|
exports.getSignup = function(req, res) {
|
||||||
if (req.user) return res.redirect('/');
|
if (req.user) return res.redirect('/');
|
||||||
res.render('account/signup', {
|
res.render('account/signup', {
|
||||||
@ -38,6 +33,7 @@ exports.getSignup = function(req, res) {
|
|||||||
* GET /account
|
* GET /account
|
||||||
* Profile page.
|
* Profile page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.getAccount = function(req, res) {
|
exports.getAccount = function(req, res) {
|
||||||
res.render('account/profile', {
|
res.render('account/profile', {
|
||||||
title: 'Account Management',
|
title: 'Account Management',
|
||||||
@ -49,14 +45,19 @@ exports.getAccount = function(req, res) {
|
|||||||
/**
|
/**
|
||||||
* POST /login
|
* POST /login
|
||||||
* Sign in using email and password.
|
* Sign in using email and password.
|
||||||
|
* @param {string} email
|
||||||
|
* @param {string} password
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.postLogin = function(req, res, next) {
|
exports.postLogin = function(req, res, next) {
|
||||||
passport.authenticate('local', function(err, user, info) {
|
passport.authenticate('local', function(err, user, info) {
|
||||||
if (err) return next(err);
|
if (err) return next(err);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
req.flash('messages', info.message);
|
req.flash('messages', info.message);
|
||||||
return res.redirect('/login');
|
return res.redirect('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
req.logIn(user, function(err) {
|
req.logIn(user, function(err) {
|
||||||
if (err) return next(err);
|
if (err) return next(err);
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
@ -67,11 +68,11 @@ exports.postLogin = function(req, res, next) {
|
|||||||
/**
|
/**
|
||||||
* POST /signup
|
* POST /signup
|
||||||
* Create a new local account.
|
* Create a new local account.
|
||||||
* @param {String} req.body.email
|
* @param {string} email
|
||||||
* @param {String} req.body.password
|
* @param {string} password
|
||||||
*/
|
*/
|
||||||
exports.postSignup = function(req, res, next) {
|
|
||||||
|
|
||||||
|
exports.postSignup = function(req, res, next) {
|
||||||
var errors = [];
|
var errors = [];
|
||||||
|
|
||||||
if (!req.body.email) {
|
if (!req.body.email) {
|
||||||
@ -136,11 +137,12 @@ exports.postUpdateProfile = function(req, res, next) {
|
|||||||
/**
|
/**
|
||||||
* POST /account/password
|
* POST /account/password
|
||||||
* Update current password.
|
* Update current password.
|
||||||
|
* @param {string} password
|
||||||
*/
|
*/
|
||||||
exports.postUpdatePassword = function(req, res, next) {
|
|
||||||
|
|
||||||
|
exports.postUpdatePassword = function(req, res, next) {
|
||||||
if (!req.body.password) {
|
if (!req.body.password) {
|
||||||
req.flash('error', 'Passwords cannot be blank.');
|
req.flash('error', 'Password cannot be blank.');
|
||||||
return res.redirect('/account');
|
return res.redirect('/account');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +167,9 @@ exports.postUpdatePassword = function(req, res, next) {
|
|||||||
/**
|
/**
|
||||||
* POST /account/delete
|
* POST /account/delete
|
||||||
* Delete user account.
|
* Delete user account.
|
||||||
|
* @param {string} id
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.postDeleteAccount = function(req, res, next) {
|
exports.postDeleteAccount = function(req, res, next) {
|
||||||
User.remove({ _id: req.user.id }, function(err) {
|
User.remove({ _id: req.user.id }, function(err) {
|
||||||
if (err) return next(err);
|
if (err) return next(err);
|
||||||
@ -177,7 +181,10 @@ exports.postDeleteAccount = function(req, res, next) {
|
|||||||
/**
|
/**
|
||||||
* GET /account/unlink/:provider
|
* GET /account/unlink/:provider
|
||||||
* Unlink OAuth2 provider from the current user.
|
* Unlink OAuth2 provider from the current user.
|
||||||
|
* @param {string} provider
|
||||||
|
* @param {string} id
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.getOauthUnlink = function(req, res, next) {
|
exports.getOauthUnlink = function(req, res, next) {
|
||||||
var provider = req.params.provider;
|
var provider = req.params.provider;
|
||||||
User.findById(req.user.id, function(err, user) {
|
User.findById(req.user.id, function(err, user) {
|
||||||
@ -197,6 +204,7 @@ exports.getOauthUnlink = function(req, res, next) {
|
|||||||
* GET /logout
|
* GET /logout
|
||||||
* Log out.
|
* Log out.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.logout = function(req, res) {
|
exports.logout = function(req, res) {
|
||||||
req.logout();
|
req.logout();
|
||||||
res.redirect('/');
|
res.redirect('/');
|
||||||
|
Reference in New Issue
Block a user