start writing validations
parent
1accb225c6
commit
ec5fea2eaa
|
@ -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 || '';
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue