kahmali / meteor-restivus

REST APIs for the Best of Us! - A Meteor 0.9+ package for building REST APIs https://atmospherejs.com/nimble/restivus
MIT License
544 stars 116 forks source link

Cannot override custom authentication error message #268

Open asthajn opened 7 years ago

asthajn commented 7 years ago

Even after including error in the response object, I am getting the default 401 error response. Can anyone describe how line no. 214
if auth.error then return { success: false, data: auth.error } is working.

My sample response logic : if(userFound) { return { user : user} } else { return {error : "not authorized"} }

achirkof commented 7 years ago

@asthajn @kahmali Hi! I have same question. For my external application it would be better to handle login error as it is described in Meteor documentation http://docs.meteor.com/api/accounts.html#Meteor-loginWithPassword Meteor.loginWithPassword can provide different error messages:

“Unrecognized options for login request [400]” if user or password is undefined.
“Match failed [400]” if user isn’t an Object or String, or password isn’t a String.
“User not found [403]” if the email or username provided in user doesn’t belong to a registered user.
“Incorrect password [403]” if the password provided is incorrect.
“User has no password set [403]” if user doesn’t have a password.

Most useful from them for me are “User not found [403]” and “Incorrect password [403]”. Is it possible to get such messages as response?