Sha256: e0fa6092474c1b8200e214effd882516f588dd13b43469849f8c589d0b6a5e47
Contents?: true
Size: 924 Bytes
Versions: 5
Compression:
Stored size: 924 Bytes
Contents
# frozen_string_literal: true require "active_support/concern" module NoPassword module WebTokens extend ActiveSupport::Concern included do def sign_token(data) secret_key = NoPassword.configuration.secret_key || Rails.application.secret_key_base verifier = ActiveSupport::MessageVerifier.new(secret_key) verifier.generate(data, expires_in: NoPassword.configuration.session_expiration, purpose: :no_password_login) end def verify_token(data) secret_key = NoPassword.configuration.secret_key || Rails.application.secret_key_base verifier = ActiveSupport::MessageVerifier.new(secret_key) token = token_from_url(data) verifier.verified(token, purpose: :no_password_login) end def token_to_url(token) CGI.escape(token) end def token_from_url(token) CGI.unescape(token) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems