FIX: on initial token issue stop unmarking token as unseen
prev and current are the same so we need special logic to bypass
This commit is contained in:
parent
ffd8fa7481
commit
3ac4709903
|
@ -64,7 +64,7 @@ class UserAuthToken < ActiveRecord::Base
|
|||
return nil
|
||||
end
|
||||
|
||||
if user_token.prev_auth_token == token && user_token.auth_token_seen
|
||||
if user_token.auth_token != token && user_token.prev_auth_token == token && user_token.auth_token_seen
|
||||
changed_rows = UserAuthToken
|
||||
.where(id: user_token.id, prev_auth_token: token)
|
||||
.update_all(auth_token_seen: false)
|
||||
|
|
|
@ -251,4 +251,18 @@ describe UserAuthToken do
|
|||
|
||||
end
|
||||
|
||||
it "will not mark token unseen when prev and current are the same" do
|
||||
user = Fabricate(:user)
|
||||
|
||||
token = UserAuthToken.generate!(user_id: user.id,
|
||||
user_agent: "some user agent",
|
||||
client_ip: "1.1.2.3")
|
||||
|
||||
|
||||
lookup = UserAuthToken.lookup(token.unhashed_auth_token, seen: true)
|
||||
lookup = UserAuthToken.lookup(token.unhashed_auth_token, seen: true)
|
||||
lookup.reload
|
||||
expect(lookup.auth_token_seen).to eq(true)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue