File tree Expand file tree Collapse file tree 4 files changed +5
-5
lines changed Expand file tree Collapse file tree 4 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ def create
11
11
current_user = @user
12
12
session [ :user_id ] = @user . id
13
13
session [ :user_cache_key ] = cookies [ :_radius_user_cache_key ]
14
- session [ :token_expires_at ] = Time . at ( auth_hash [ :credentials ] [ :expires_at ] )
14
+ session [ :token_expires_at ] = Time . zone . at ( auth_hash [ :credentials ] [ :expires_at ] )
15
15
redirect_to return_to_path
16
16
end
17
17
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def authenticate_user!
45
45
end
46
46
47
47
def check_token_expiry!
48
- if session [ :token_expires_at ] . nil? || session [ :token_expires_at ] < Time . now
48
+ if session [ :token_expires_at ] . nil? || session [ :token_expires_at ] < Time . zone . now
49
49
session . delete :user_id
50
50
end
51
51
end
Original file line number Diff line number Diff line change @@ -95,15 +95,15 @@ class ControllerDouble < BaseControllerDouble
95
95
it "redirects to sign-in when token has expired" do
96
96
allow ( controller ) . to receive ( :request ) . and_return ( double ( format : nil , fullpath : nil ) )
97
97
allow ( controller ) . to receive ( :redirect_to )
98
- controller . session [ :token_expires_at ] = 5 . minutes . ago
98
+ controller . session [ :token_expires_at ] = Time . zone . now - 5 . minutes
99
99
controller . authenticate_user!
100
100
expect ( controller ) . to have_received ( :redirect_to )
101
101
end
102
102
103
103
it "authenticates user when token has not expired" do
104
104
allow ( controller ) . to receive ( :request ) . and_return ( double ( format : nil , fullpath : nil ) )
105
105
allow ( controller ) . to receive ( :redirect_to )
106
- controller . session [ :token_expires_at ] = Time . now + 5 . minutes
106
+ controller . session [ :token_expires_at ] = Time . zone . now + 5 . minutes
107
107
controller . authenticate_user!
108
108
expect ( controller ) . to_not have_received ( :redirect_to )
109
109
end
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def headers_with_token(token)
31
31
it "sets :token_expires_at in the session" do
32
32
OmniAuth . config . mock_auth [ :radius ] = OmniAuth ::AuthHash . new ( auth_hash )
33
33
get "/auth/radius/callback"
34
- expect ( request . session [ :token_expires_at ] ) . to eq ( Time . at ( token_expiry ) )
34
+ expect ( request . session [ :token_expires_at ] ) . to eq ( Time . zone . at ( token_expiry ) )
35
35
end
36
36
end
37
37
end
You can’t perform that action at this time.
0 commit comments