mirror of
https://github.com/discourse/discourse.git
synced 2026-08-12 05:55:39 -05:00
correct miscellaneous issues with user login history
This commit is contained in:
@@ -250,6 +250,25 @@ describe UserAuthToken do
|
||||
|
||||
end
|
||||
|
||||
it "calls before_destroy" do
|
||||
SiteSetting.verbose_auth_token_logging = true
|
||||
|
||||
user = Fabricate(:user)
|
||||
|
||||
token = UserAuthToken.generate!(user_id: user.id,
|
||||
user_agent: "some user agent",
|
||||
client_ip: "1.1.2.3")
|
||||
|
||||
expect(user.user_auth_token_logs.count).to eq(1)
|
||||
|
||||
token.destroy
|
||||
|
||||
expect(user.user_auth_token_logs.count).to eq(2)
|
||||
expect(user.user_auth_token_logs.last.action).to eq("destroy")
|
||||
expect(user.user_auth_token_logs.last.user_agent).to eq("some user agent")
|
||||
expect(user.user_auth_token_logs.last.client_ip).to eq("1.1.2.3")
|
||||
end
|
||||
|
||||
it "will not mark token unseen when prev and current are the same" do
|
||||
user = Fabricate(:user)
|
||||
|
||||
|
||||
@@ -3167,4 +3167,24 @@ describe UsersController do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#revoke_auth_token' do
|
||||
|
||||
context 'while logged in' do
|
||||
before do
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
it 'logs user out' do
|
||||
expect(user.user_auth_tokens.count).to eq(1)
|
||||
|
||||
post "/u/#{user.username}/preferences/revoke-auth-token.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(user.user_auth_tokens.count).to eq(0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user