Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning 401 causes a mystery redirect #39

Closed
nshCore opened this issue Oct 28, 2016 · 2 comments
Closed

Returning 401 causes a mystery redirect #39

nshCore opened this issue Oct 28, 2016 · 2 comments

Comments

@nshCore
Copy link

nshCore commented Oct 28, 2016

In my app if the users credentials don't authenticate it returns a 401 http status code. Which causes vue-auth.js to do some mystery redirect back '/' rather than displaying the error. If a users credentials arent found a 404 is returned which prints the error returned. for the time being i am returning a 403 forbidden http status. Can you tell me how i disable this redirect for 401 responses

@websanova
Copy link
Owner

You can just overwrite the invalid token method.

_invalidToken: function (res) {
if (res.status === 401) {
this.logout();
}
},

Right now it just does a force logout (to account for states where 401
while logged in, etc). The logout just cleans up all the tokens, etc, so
that it doesn't try to use a stale token later on.

In this case the redirect is coming from the logout data.

logoutData: {url: 'auth/logout', method: 'POST', redirect:
'/', makeRequest: false},

So there are a few ways to deal with it. You can just set some default in
the logoutData.redirect. This is just a generic default. You can still call
$auth.logout({redirect: 'here'}) later on to override that. Or if you wanna
get fancy just override call logout({redirect: null}) in the _invalidtoken
mehtod and do your own thing after that.

On Sat, Oct 29, 2016 at 1:06 AM, jkirkby91-2 notifications@github.com
wrote:

In my app if the users credentials don't authenticate it returns a 401
http status code. Which causes vue-auth.js to do some mystery redirect back
'/' rather than displaying the error. If a users credentials arent found a
404 is returned which prints the error returned. for the time being i am
returning a 403 forbidden http status. Can you tell me how i disable this
redirect for 401 responses


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#39, or mute the thread
https://github.com/notifications/unsubscribe-auth/ABkcyy1YwL_nbIMEIZ3ICnxZ7JBVdLjiks5q4jmQgaJpZM4KjtE6
.

Robert Duchnik
http://www.duchnik.com

@websanova
Copy link
Owner

Any luck here, can close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants