File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
login , sign-up rest api's Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,13 @@ mongooses.connect(db).then(()=>{
2727app . post ( '/api/signup' , function ( req , res ) {
2828 // taking a user
2929 var newUser = new User ( {
30+ name :req . body . name ,
3031 email : req . body . email ,
31- password : req . body . password
32+ password : req . body . password ,
33+ password2 :req . body . password
3234 } ) ;
35+ if ( password != password2 )
36+ return res . status ( 400 ) . json ( { message : "passwords don't match" } ) ;
3337
3438 // checking whether user is already registered or not
3539 User . findOne ( { email : newUser . email } , function ( err , user ) {
Original file line number Diff line number Diff line change @@ -3,14 +3,19 @@ const bcrypt =require('bcrypt');
33const jwt = require ( 'jsonwebtoken' ) ;
44const config = require ( './../config/config' ) . get ( process . env . NODE_ENV ) ;
55const UserSchema = mongoose . Schema ( {
6+ name :{
7+ type : String ,
8+ required : true
9+ } ,
610 email :{
711 type :String ,
8- require : true
12+ required : true
913 } ,
1014 password :{
1115 type :String ,
12- require : true
13- }
16+ required : true
17+ } ,
18+
1419} ) ;
1520UserSchema . methods . generateToken = function ( cb ) {
1621 var user = this ;
You can’t perform that action at this time.
0 commit comments