diff --git a/README.md b/README.md
index 8fe87a7705..ed49096013 100644
--- a/README.md
+++ b/README.md
@@ -73,11 +73,11 @@ Prerequisites
- [MongoDB](http://www.mongodb.org/downloads)
- [Node.js](http://nodejs.org)
- Command Line Tools
- - **Mac OS X**: [Xcode](https://itunes.apple.com/us/app/xcode/id497799835?mt=12) (or **OS X 10.9 Mavericks**: `xcode-select --install`)
- - **Windows**: [Visual Studio](http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-8)
- - **Ubuntu**: `sudo apt-get install build-essential`
- - **Fedora**: `sudo yum groupinstall "Development Tools"`
- - **OpenSUSE**: `sudo zypper install --type pattern devel_basis`
+ - **Mac OS X**: [Xcode](https://itunes.apple.com/us/app/xcode/id497799835?mt=12) (or **OS X 10.9 Mavericks**: `xcode-select --install`)
+ - **Windows**: [Visual Studio](http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-8)
+ - **Ubuntu**: `sudo apt-get install build-essential`
+ - **Fedora**: `sudo yum groupinstall "Development Tools"`
+ - **OpenSUSE**: `sudo zypper install --type pattern devel_basis`
:exclamation: **Note**: If you are new to Node.js or Express framework,
I highly recommend watching [Node.js and Express 101](http://www.youtube.com/watch?v=BN0JlMZCtNU) screencast by Alex Ford that teaches Node and Express from scratch. Alternatively, here is another great tutorial for complete beginners - [Getting Started With Node.js, Express, MongoDB](http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/).
@@ -503,7 +503,7 @@ to "info" and "success" flash messages, and you could even create a new one your
**Data Usage Controller (Example)**
```
-req.flash('warning', 'You have exceeded 90% of your data usage');
+req.flash('warning', {msg: 'You have exceeded 90% of your data usage'});
```
**User Account Page (Example)**
@@ -846,7 +846,7 @@ TODO
Contributing
------------
-If something is unclear, confusing, or needs to be refactored, please let me know. Pull requests are always welcome, but due to the opinionated nature of this project, I cannot accept every pull request. Please open an issue before submitting a pull request.
+If something is unclear, confusing, or needs to be refactored, please let me know. Pull requests are always welcome, but due to the opinionated nature of this project, I cannot accept every pull request. Please open an issue before submitting a pull request. This project uses [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) with a few exceptions.
License
-------
diff --git a/controllers/api.js b/controllers/api.js
index 53493b8672..0bd1c493ae 100644
--- a/controllers/api.js
+++ b/controllers/api.js
@@ -398,6 +398,7 @@ exports.getTwilio = function(req, res, next) {
/**
* POST /api/twilio
* Twilio API example.
+ * @param telephone
*/
exports.postTwilio = function(req, res, next) {
diff --git a/controllers/contact.js b/controllers/contact.js
index a8848299a5..8ec66877ae 100644
--- a/controllers/contact.js
+++ b/controllers/contact.js
@@ -15,9 +15,9 @@ exports.getContact = function(req, res) {
/**
* POST /contact
* Send a contact form via SendGrid.
- * @param {string} email
- * @param {string} name
- * @param {string} message
+ * @param email
+ * @param name
+ * @param message
*/
exports.postContact = function(req, res) {
diff --git a/controllers/user.js b/controllers/user.js
index 525712e4b9..c8680601ff 100644
--- a/controllers/user.js
+++ b/controllers/user.js
@@ -1,4 +1,3 @@
-var mongoose = require('mongoose');
var passport = require('passport');
var _ = require('underscore');
var User = require('../models/User');
@@ -18,8 +17,8 @@ exports.getLogin = function(req, res) {
/**
* POST /login
* Sign in using email and password.
- * @param {string} email
- * @param {string} password
+ * @param email
+ * @param password
*/
exports.postLogin = function(req, res, next) {
@@ -48,6 +47,16 @@ exports.postLogin = function(req, res, next) {
})(req, res, next);
};
+/**
+ * GET /logout
+ * Log out.
+ */
+
+exports.logout = function(req, res) {
+ req.logout();
+ res.redirect('/');
+};
+
/**
* GET /signup
* Signup page.
@@ -63,8 +72,8 @@ exports.getSignup = function(req, res) {
/**
* POST /signup
* Create a new local account.
- * @param {string} email
- * @param {string} password
+ * @param email
+ * @param password
*/
exports.postSignup = function(req, res, next) {
@@ -134,7 +143,7 @@ exports.postUpdateProfile = function(req, res, next) {
/**
* POST /account/password
* Update current password.
- * @param {string} password
+ * @param password
*/
exports.postUpdatePassword = function(req, res, next) {
@@ -164,7 +173,7 @@ exports.postUpdatePassword = function(req, res, next) {
/**
* POST /account/delete
* Delete user account.
- * @param {string} id
+ * @param id - User ObjectId
*/
exports.postDeleteAccount = function(req, res, next) {
@@ -178,8 +187,8 @@ exports.postDeleteAccount = function(req, res, next) {
/**
* GET /account/unlink/:provider
* Unlink OAuth2 provider from the current user.
- * @param {string} provider
- * @param {string} id
+ * @param provider
+ * @param id - User ObjectId
*/
exports.getOauthUnlink = function(req, res, next) {
@@ -197,13 +206,3 @@ exports.getOauthUnlink = function(req, res, next) {
});
});
};
-
-/**
- * GET /logout
- * Log out.
- */
-
-exports.logout = function(req, res) {
- req.logout();
- res.redirect('/');
-};
diff --git a/models/User.js b/models/User.js
index 543a393a6e..e8203720ae 100644
--- a/models/User.js
+++ b/models/User.js
@@ -56,8 +56,7 @@ userSchema.methods.comparePassword = function(candidatePassword, cb) {
userSchema.methods.gravatar = function(size, defaults) {
if (!size) size = 200;
if (!defaults) defaults = 'retro';
- var md5 = crypto.createHash('md5');
- md5.update(this.email);
+ var md5 = crypto.createHash('md5').update(this.email);
return 'https://gravatar.com/avatar/' + md5.digest('hex').toString() + '?s=' + size + '&d=' + defaults;
};
diff --git a/public/js/application.js b/public/js/application.js
index 61d42a8e4a..54232de136 100644
--- a/public/js/application.js
+++ b/public/js/application.js
@@ -1,13 +1,13 @@
-// This is a manifest file that'll be compiled into application.js, which will include all the files
-// listed below.
-//
-// Any JavaScript/Coffee file within this directory can be referenced here using a relative path.
-//
-// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
-// compiled file.
-//
-// Read Connect Assets README (https://github.com/adunkman/connect-assets) for details
-// about supported directives.
+/**
+ * This is a manifest file that will be compiled into application.js, which will
+ * include all the files listed below.
+ *
+ * Any JavaScript file within this directory can be referenced here using a
+ * relative path.
+ *
+ * It's not advisable to add code directly here, but if you do, it will appear
+ * at the bottom of the compiled file.
+ */
//= require lib/jquery-2.1.0.min
//= require lib/bootstrap.min
diff --git a/views/account/login.jade b/views/account/login.jade
index a97954cdc8..a52022d164 100644
--- a/views/account/login.jade
+++ b/views/account/login.jade
@@ -3,6 +3,7 @@ extends ../layout
block content
.col-sm-8.col-sm-offset-2
form(method='POST')
+ input(type='hidden', name='_csrf', value=token)
legend Sign In
.form-group
.btn-group.btn-group-justified
@@ -22,16 +23,15 @@ block content
a.btn.btn-google-plus(href='/auth/google')
i.fa.fa-google-plus
| Google
- if secrets.localAuth
- .form-group
- label.control-label(for='email') Email
- input.form-control(type='text', name='email', id='email', placeholder='Email', autofocus=true)
- .form-group
- label.control-label(for='password') Password
- input.form-control(type='password', name='password', id='password', placeholder='Password')
- .form-group
- input.form-control(type='hidden', name='_csrf', value=token)
- .form-group
- button.btn.btn-primary(type='submit')
- i.fa.fa-unlock-alt
- | Login
+ if secrets.localAuth
+ .form-group
+ label.control-label(for='email') Email
+ input.form-control(type='text', name='email', id='email', placeholder='Email', autofocus=true)
+ .form-group
+ label.control-label(for='password') Password
+ input.form-control(type='password', name='password', id='password', placeholder='Password')
+ .form-group
+ button.btn.btn-primary(type='submit')
+ i.fa.fa-unlock-alt
+ | Login
+
diff --git a/views/account/profile.jade b/views/account/profile.jade
index fb8d6ace79..85dd1ca1ba 100644
--- a/views/account/profile.jade
+++ b/views/account/profile.jade
@@ -5,6 +5,7 @@ block content
h3 Profile Information
form.form-horizontal(action='/account/profile', method='POST')
+ input(type='hidden', name='_csrf', value=token)
.form-group
label.col-sm-2.control-label(for='email') Email
.col-sm-4
@@ -34,8 +35,6 @@ block content
label.col-sm-2.control-label(for='gravatar') Gravatar
.col-sm-4
img(src="#{user.gravatar()}", class='profile', width='100', height='100')
- .form-group
- input.form-control(type='hidden', name='_csrf', value=token)
.form-group
.col-sm-offset-2.col-sm-4
button.btn.btn.btn-primary(type='submit')
@@ -46,29 +45,29 @@ block content
if secrets.localAuth
.page-header
h3 Change Password
-
- form.form-horizontal(action='/account/password', method='POST')
- .form-group
- label.col-sm-3.control-label(for='password') New Password
- .col-sm-4
- input.form-control(type='password', name='password', id='password')
- .form-group
- label.col-sm-3.control-label(for='confirmPassword') Confirm Password
- .col-sm-4
- input.form-control(type='password', name='confirmPassword', id='confirmPassword')
- .form-group
- input.form-control(type='hidden', name='_csrf', value=token)
- .form-group
- .col-sm-offset-3.col-sm-4
- button.btn.btn.btn-primary(type='submit')
- i.fa.fa-keyboard-o
- | Change Password
+
+ form.form-horizontal(action='/account/password', method='POST')
+ input(type='hidden', name='_csrf', value=token)
+ .form-group
+ label.col-sm-3.control-label(for='password') New Password
+ .col-sm-4
+ input.form-control(type='password', name='password', id='password')
+ .form-group
+ label.col-sm-3.control-label(for='confirmPassword') Confirm Password
+ .col-sm-4
+ input.form-control(type='password', name='confirmPassword', id='confirmPassword')
+ .form-group
+ .col-sm-offset-3.col-sm-4
+ button.btn.btn.btn-primary(type='submit')
+ i.fa.fa-keyboard-o
+ | Change Password
.page-header
h3 Delete Account
p You can delete your account, but keep in mind this action is irreversible.
form(action='/account/delete', method='POST')
+ input(type='hidden', name='_csrf', value=token)
button.btn.btn-danger(type='submit')
i.fa.fa-trash-o
| Delete my account
diff --git a/views/account/signup.jade b/views/account/signup.jade
index c151918e37..a2a8be6681 100644
--- a/views/account/signup.jade
+++ b/views/account/signup.jade
@@ -2,6 +2,7 @@ extends ../layout
block content
form.form-horizontal(id='signup-form', method='POST')
+ input(type='hidden', name='_csrf', value=token)
legend Signup
.form-group
label.col-sm-3.control-label(for='email') Email
@@ -15,8 +16,6 @@ block content
label.col-sm-3.control-label(for='confirmPassword') Confirm Password
.col-sm-7
input.form-control(type='password', name='confirmPassword', id='confirmPassword', placeholder='Confirm Password')
- .form-group
- input.form-control(type='hidden', name='_csrf', value=token)
.form-group
.col-sm-offset-3.col-sm-7
button.btn.btn-success(type='submit')
diff --git a/views/contact.jade b/views/contact.jade
index 44449c11b0..f6b4e7105e 100644
--- a/views/contact.jade
+++ b/views/contact.jade
@@ -5,6 +5,7 @@ block content
h3 Contact Form
form.form-horizontal(role='form', method='POST')
+ input(type='hidden', name='_csrf', value=token)
.form-group
label(class='col-sm-2 control-label', for='name') Name
.col-sm-8
@@ -17,8 +18,6 @@ block content
label(class='col-sm-2 control-label', for='message') Body
.col-sm-8
textarea.form-control(type='text', name='message', id='message', rows='7')
- .form-group
- input.form-control(type='hidden', name='_csrf', value=token)
.form-group
.col-sm-offset-2.col-sm-8
button.btn.btn-default(type='submit')
diff --git a/views/partials/navigation.jade b/views/partials/navigation.jade
index c157ac7cd9..8aa337e15c 100644
--- a/views/partials/navigation.jade
+++ b/views/partials/navigation.jade
@@ -28,7 +28,7 @@
if user.profile.picture
img.profile-image(src='#{user.profile.picture}')
else
- img.profile-image(src='#{user.gravatar()}')
+ img.profile-image(src='#{user.gravatar(60)}')
| #{user.profile.name || user.email || user.id}
i.caret
ul.dropdown-menu