@@ -81,7 +81,7 @@ UserSchema
8181 // returns only first found email
8282 // TODO: in case of multiple emails, should prioritize confirmed ones
8383 return this . credentials . filter ( function ( c ) {
84- return c . type === 'email' ;
84+ return c . type === 'email' ;
8585
8686 } ) [ 0 ] . value ;
8787} ) ;
@@ -90,21 +90,21 @@ UserSchema
9090. virtual ( 'emails' )
9191. get ( function ( ) {
9292 return this . credentials
93- . filter ( function ( c ) { return c . type === 'email' ; } )
93+ . filter ( function ( c ) { return c . type === 'email' ; } )
9494 . map ( function ( c ) { return c . value ; } ) ;
9595
9696} ) ;
9797
9898UserSchema
9999. pre ( 'save' , function ( next ) { < % if ( filters . oauth ) { % >
100100 if ( ! this . localEnabled ) {
101- if ( Object . keys ( this . strategies ) . length === 0 ) {
101+ if ( Object . keys ( this . strategies ) . length === 0 ) {
102102 return next ( new Error ( 'No connected accounts' ) ) ;
103103 }
104104 return next ( ) ;
105105 } < % } % >
106106
107- mongoose . models [ ' User' ] < % if ( filters . oauth ) { % >
107+ mongoose . models . User < % if ( filters . oauth ) { % >
108108 . find ( { localEnabled :true } ) < % } % >
109109 . where ( 'credentials.type' ) . equals ( 'email' )
110110 . where ( 'credentials.value' ) . equals ( this . email )
@@ -132,15 +132,15 @@ UserSchema.methods = {
132132 } ,
133133 confirm : function ( emailOrPhone , cb ) {
134134 this . credentials . forEach ( function ( c ) {
135- if ( c . value === emailOrPhone ) {
135+ if ( c . value === emailOrPhone ) {
136136 c . confirmed = true ;
137137 }
138138 } ) ;
139139 this . save ( cb ) ;
140140 } ,
141141 changeEmail : function ( oldEmail , newEmail , cb ) {
142142 this . credentials . forEach ( function ( c ) {
143- if ( c . value === oldEmail ) {
143+ if ( c . value === oldEmail ) {
144144 c . value = newEmail ;
145145 c . confirmed = false ;
146146 }
@@ -177,14 +177,14 @@ UserSchema.statics = {
177177 var dataFormatted ;
178178 dataFormatted = [ ] ;
179179
180- if ( data . email != null ) {
180+ if ( data . email !== null ) {
181181 dataFormatted . push ( {
182182 'credentials.type' : 'email' ,
183183 'credentials.value' : data . email
184184 } ) ;
185185 }
186186
187- if ( data . phone != null ) {
187+ if ( data . phone !== null ) {
188188 dataFormatted . push ( {
189189 'credentials.type' : 'phone' ,
190190 'credentials.value' : data . phone
@@ -195,11 +195,11 @@ UserSchema.statics = {
195195 . or ( dataFormatted )
196196 . exec ( function ( err , users ) {
197197 if ( err ) return cb ( err ) ;
198- if ( users . length === 0 ) return cb ( null , null ) ;
198+ if ( users . length === 0 ) return cb ( null , null ) ;
199199
200200 cb ( null , users ) ;
201201 } ) ;
202202 } < % } % >
203203} ;
204204
205- module . exports = mongoose . model ( 'User' , UserSchema ) ;
205+ module . exports = mongoose . model ( 'User' , UserSchema ) ;
0 commit comments