@ -10,6 +10,9 @@ const Errors = {
INVALID _PASSWORD : {
INVALID _PASSWORD : {
invalidPassword : 'Invalid password' ,
invalidPassword : 'Invalid password' ,
} ,
} ,
INVALID _CREDENTIALS : {
invalidCredentials : 'Invalid credentials' ,
} ,
USE _SINGLE _SIGN _ON : {
USE _SINGLE _SIGN _ON : {
useSingleSignOn : 'Use single sign-on' ,
useSingleSignOn : 'Use single sign-on' ,
} ,
} ,
@ -40,6 +43,9 @@ module.exports = {
invalidPassword : {
invalidPassword : {
responseType : 'unauthorized' ,
responseType : 'unauthorized' ,
} ,
} ,
invalidCredentials : {
responseType : 'unauthorized' ,
} ,
useSingleSignOn : {
useSingleSignOn : {
responseType : 'forbidden' ,
responseType : 'forbidden' ,
} ,
} ,
@ -57,6 +63,9 @@ module.exports = {
sails . log . warn (
sails . log . warn (
` Invalid email or username: " ${ inputs . emailOrUsername } "! (IP: ${ remoteAddress } ) ` ,
` Invalid email or username: " ${ inputs . emailOrUsername } "! (IP: ${ remoteAddress } ) ` ,
) ;
) ;
if ( ! sails . config . custom . enableVerboseOnLogin ) {
throw Errors . INVALID _CREDENTIALS ;
}
throw Errors . INVALID _EMAIL _OR _USERNAME ;
throw Errors . INVALID _EMAIL _OR _USERNAME ;
}
}
@ -66,6 +75,9 @@ module.exports = {
if ( ! bcrypt . compareSync ( inputs . password , user . password ) ) {
if ( ! bcrypt . compareSync ( inputs . password , user . password ) ) {
sails . log . warn ( ` Invalid password! (IP: ${ remoteAddress } ) ` ) ;
sails . log . warn ( ` Invalid password! (IP: ${ remoteAddress } ) ` ) ;
if ( ! sails . config . custom . enableVerboseOnLogin ) {
throw Errors . INVALID _CREDENTIALS ;
}
throw Errors . INVALID _PASSWORD ;
throw Errors . INVALID _PASSWORD ;
}
}