Logout with active_sessions feature does not invalidate JWT #238
-
Hi there, here's my test context 'Without Global logout' do
it "invalidates the JWT" do
account = create(:user)
# login user
post "/v1/auth/login", as: :json, params: {
email: account.email,
password: account.password
}
expect(response).to have_http_status(200)
bearer_token = response.headers["Authorization"]
# logout
post "/v1/auth/logout", as: :json
new_password = "newpassword"
# attempt to change user password with same JWT (bearer_token)
post "/v1/auth/change-password", as: :json, params: {
password: account.password,
new_password: new_password,
password_confirmation: new_password
}, headers: { Authorization: bearer_token }
expect(response).to have_http_status(401)
error_message = response.parsed_body.fetch("error")
expect(error_message).to eq "Please login to continue"
end
end The change password response comes back successful instead of failing. I've added the feature to the config file. Is there anything I'm doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Are you calling route do |r|
rodauth(:v1).check_active_session
r.rodauth(:v1)
end I just added a test to the official demo app, and it works just fine, logout does invalidate the previous token. |
Beta Was this translation helpful? Give feedback.
Are you calling
rodauth.check_active_session
in theroute
block? That's what actually checks whether the current session is active and doesn't let the request go through otherwise.I just added a test to the official demo app, and it works just fine, logout does invalidate the previous token.