mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 23:33:56 +08:00
ff49f72ad9
Revamped system for managing authentication tokens. - Every user has 1 token per client (web browser) - Tokens are rotated every 10 minutes New system migrates the old tokens to "legacy" tokens, so users still remain logged on. Also introduces weekly job to expire old auth tokens.
14 lines
403 B
Ruby
14 lines
403 B
Ruby
require 'rails_helper'
|
|
require_dependency 'current_user'
|
|
|
|
describe CurrentUser do
|
|
it "allows us to lookup a user from our environment" do
|
|
user = Fabricate(:user, active: true)
|
|
token = UserAuthToken.generate!(user_id: user.id)
|
|
|
|
env = Rack::MockRequest.env_for("/test", "HTTP_COOKIE" => "_t=#{token.unhashed_auth_token};")
|
|
expect(CurrentUser.lookup_from_env(env)).to eq(user)
|
|
end
|
|
|
|
end
|