Class: Remotty::Rails::Authentication::Strategies::TokenHeaderAuthenticable
- Inherits:
-
Devise::Strategies::Base
- Object
- Devise::Strategies::Base
- Remotty::Rails::Authentication::Strategies::TokenHeaderAuthenticable
- Defined in:
- lib/remotty/rails/authentication/strategies/token_header_authenticable.rb
Instance Method Summary collapse
-
#authenticate! ⇒ Object
email에 해당하는 token을 auth_token 테이블에서 확인.
-
#store? ⇒ Boolean
use session?.
-
#valid? ⇒ Boolean
개발일 경우는 email만 있어도 통과! 아니면 email + token header 필요.
Instance Method Details
#authenticate! ⇒ Object
email에 해당하는 token을 auth_token 테이블에서 확인
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/remotty/rails/authentication/strategies/token_header_authenticable.rb', line 27 def authenticate! resource_scope = mapping.to resource = resource_scope.find_by_email(header_email) if resource if ENV["RAILS_ENV"] == "development"# && header_token.nil? success!(resource) else auth_token = resource.auth_tokens.where("token = ? and updated_at > ?", Digest::SHA512.hexdigest(header_token), mapping.to.remember_for.ago).first if auth_token auth_token.update_source source, source_info success!(resource) else fail! end end else fail! end end |
#store? ⇒ Boolean
use session?
17 18 19 |
# File 'lib/remotty/rails/authentication/strategies/token_header_authenticable.rb', line 17 def store? super && !mapping.to.skip_session_storage.include?(:token_header_auth) end |
#valid? ⇒ Boolean
개발일 경우는 email만 있어도 통과! 아니면 email + token header 필요
22 23 24 |
# File 'lib/remotty/rails/authentication/strategies/token_header_authenticable.rb', line 22 def valid? header_email && (ENV["RAILS_ENV"] == "development" || header_token) end |