diff --git a/controllers/user.js b/controllers/user.js index 1eacc834652..44224a98b5b 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -158,7 +158,7 @@ exports.postUpdateProfile = function(req, res, next) { if (err) return next(err); user.email = req.body.email || ''; user.profile.name = req.body.name || ''; - user.profile.gender = req.body.gender || ''; + user.profile.username = req.body.username || ''; user.profile.location = req.body.location || ''; user.profile.website = req.body.website || ''; diff --git a/models/User.js b/models/User.js index c0be17eb0e7..06e94d65d87 100644 --- a/models/User.js +++ b/models/User.js @@ -3,7 +3,7 @@ var crypto = require('crypto'); var mongoose = require('mongoose'); var userSchema = new mongoose.Schema({ - email: { type: String, unique: true, lowercase: true }, + email: { type: String, unique: true, lowercase: true, match: /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/ }, password: String, facebook: String, @@ -21,7 +21,7 @@ var userSchema = new mongoose.Schema({ location: { type: String, default: '' }, website: { type: String, default: '' }, picture: { type: String, default: '' }, - username: { type: String, default: '' } + username: { type: String, default: '', unique: true, match: /^[a-zA-Z0-9_]+$/ } }, resetPasswordToken: String, diff --git a/views/account/profile.jade b/views/account/profile.jade index a7b443c7a0c..63d1717652e 100644 --- a/views/account/profile.jade +++ b/views/account/profile.jade @@ -7,14 +7,18 @@ block content .animated.flipInX form.form-horizontal(action='/account/profile', method='POST') input(type='hidden', name='_csrf', value=_csrf) - .form-group - label.col-sm-2.control-label(for='email') Email - .col-sm-4 - input.form-control(type='email', name='email', id='email', value='#{user.email}') .form-group label.col-sm-2.control-label(for='name') Name .col-sm-4 input.form-control(type='text', name='name', id='name', value='#{user.profile.name}') + .form-group + label.col-sm-2.control-label(for='username') Username + .col-sm-4 + input.form-control(type='text', name='username', id='username', value='#{user.profile.username}') + .form-group + label.col-sm-2.control-label(for='email') Email + .col-sm-4 + input.form-control(type='email', name='email', id='email', value='#{user.email}') .form-group label.col-sm-2.control-label(for='location') Location .col-sm-4