@@ -9,9 +9,6 @@ module ActsAsJwtAuthenticatable
99 private :generate_authentication_token
1010 private :token_suitable?
1111 private :token_generator
12-
13- mattr_accessor :jwt_timeout
14- mattr_accessor :jwt_timeout_remember_me
1512 end
1613
1714 def ensure_authentication_token
@@ -40,7 +37,7 @@ def token_generator
4037 end
4138
4239 def jwt_token ( remember = false )
43- data = self . class . instance_variable_get ( "@ jwt_key_fields" ) . inject ( { } ) { |hash , field | hash [ field ] = self . send field ; hash }
40+ data = self . class . jwt_key_fields . inject ( { } ) { |hash , field | hash [ field ] = self . send field ; hash }
4441 payload = {
4542 exp : ( Time . now + jwt_session_duration ( remember ) ) . to_i ,
4643 self . class . name . underscore => data
@@ -55,9 +52,21 @@ def jwt_session_duration(remember = false)
5552 module ClassMethods
5653 def acts_as_jwt_authenticatable ( options = { } )
5754 before_save :ensure_authentication_token
58- self . jwt_timeout_remember_me = options [ :timeout_remember_me ] || JwtAuthentication . jwt_timeout_remember_me
59- self . jwt_timeout = options [ :timeout ] || JwtAuthentication . jwt_timeout
60- self . instance_variable_set ( "@jwt_key_fields" , options [ :key_fields ] || JwtAuthentication . key_fields )
55+ @jwt_timeout_remember_me = options [ :timeout_remember_me ] || JwtAuthentication . jwt_timeout_remember_me
56+ @jwt_timeout = options [ :timeout ] || JwtAuthentication . jwt_timeout
57+ @jwt_key_fields = options [ :key_fields ] || JwtAuthentication . key_fields
58+ end
59+
60+ def jwt_timeout
61+ self . instance_variable_get ( "@jwt_timeout" )
62+ end
63+
64+ def jwt_timeout_remember_me
65+ self . instance_variable_get ( "@jwt_timeout_remember_me" )
66+ end
67+
68+ def jwt_key_fields
69+ self . instance_variable_get ( "@jwt_key_fields" )
6170 end
6271 end
6372 end
0 commit comments