@@ -44,17 +44,6 @@ app.get( '/' , function( req, res ) {
4444} ) ;
4545
4646app . post ( '/' , function ( req , res ) {
47- if ( req . body . firstname === undefined ||
48- req . body . lastname === undefined ||
49- req . body . password === undefined ||
50- req . body . verify === undefined ||
51- req . body . email === undefined ||
52- req . body . address === undefined ) {
53- req . flash ( 'danger' , messages [ 'information-ommited' ] ) ;
54- res . redirect ( app . mountpath ) ;
55- return ;
56- }
57-
5847 if ( req . user ) {
5948 req . flash ( 'warning' , messages [ 'already-logged-in' ] ) ;
6049 res . redirect ( '/profile' ) ;
@@ -66,17 +55,19 @@ app.post( '/', function( req, res ) {
6655 address : req . body . address ,
6756 } ;
6857
69- if ( req . body . firstname === '' ) {
58+ if ( ! req . body . firstname ) {
7059 req . flash ( 'danger' , messages [ 'user-firstname' ] ) ;
7160 res . render ( 'index' , { user : user } ) ;
7261 return ;
7362 }
74- if ( req . body . lastname === '' ) {
63+
64+ if ( ! req . body . lastname ) {
7565 req . flash ( 'danger' , messages [ 'user-lastname' ] ) ;
7666 res . render ( 'index' , { user : user } ) ;
7767 return ;
7868 }
79- if ( req . body . address === '' ) {
69+
70+ if ( ! req . body . address ) {
8071 req . flash ( 'danger' , messages [ 'user-address' ] ) ;
8172 res . render ( 'index' , { user : user } ) ;
8273 return ;
@@ -98,11 +89,11 @@ app.post( '/', function( req, res ) {
9889 var postcode = '' ;
9990 var results = req . body . address . match ( / ( [ A - P R - U W Y Z 0 - 9 ] [ A - H K - Y 0 - 9 ] [ A E H M N P R T V X Y 0 - 9 ] ? [ A B E H M N P R V W X Y 0 - 9 ] ? { 1 , 2 } [ 0 - 9 ] [ A B D - H J L N - U W - Z ] { 2 } | G I R 0 A A ) / ) ;
10091
101- if ( results !== undefined ) {
92+ if ( results ) {
10293 postcode = results [ 0 ] ;
10394 }
10495 postcodes . lookup ( postcode , function ( err , data ) {
105- if ( data !== undefined ) {
96+ if ( data ) {
10697 user . postcode_coordinates = {
10798 lat : data . latitude ,
10899 lng : data . longitude ,
@@ -120,8 +111,8 @@ app.post( '/', function( req, res ) {
120111
121112 // Store new member
122113 new Members ( user ) . save ( function ( status ) {
123- if ( status !== null ) {
124- if ( status . errors !== undefined ) {
114+ if ( status ) {
115+ if ( status . errors ) {
125116 var keys = Object . keys ( status . errors ) ;
126117 for ( var k in keys ) {
127118 var key = keys [ k ] ;
0 commit comments