Module: UserManagementRails

Defined in:
lib/user_management_rails.rb,
lib/user_management_rails/engine.rb,
lib/user_management_rails/version.rb,
app/jobs/user_management_rails/application_job.rb,
app/helpers/user_management_rails/logins_helper.rb,
app/models/user_management_rails/application_record.rb,
app/helpers/user_management_rails/application_helper.rb,
app/mailers/user_management_rails/application_mailer.rb,
lib/generators/user_management_rails/install_generator.rb,
app/controllers/user_management_rails/logins_controller.rb,
app/controllers/user_management_rails/application_controller.rb

Defined Under Namespace

Modules: ApplicationHelper, LoginsHelper Classes: ApplicationController, ApplicationJob, ApplicationMailer, ApplicationRecord, Configuration, Engine, InstallGenerator, LoginsController

Constant Summary collapse

VERSION =
'0.1.6'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



25
26
27
# File 'lib/user_management_rails.rb', line 25

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



28
29
30
31
# File 'lib/user_management_rails.rb', line 28

def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

.decode_user(jwt) ⇒ Object



6
7
8
9
10
# File 'lib/user_management_rails.rb', line 6

def self.decode_user(jwt)
  # pub_key = OpenSSL::PKey::RSA.new(ENV['JWT_PUBLIC_KEY'])
  pub_key = OpenSSL::PKey::RSA.new(self.configuration.jwt_public_key)
  JWT.decode(jwt, pub_key, true, algorithm: 'RS256')[0]
end

.valid_jwt?(jwt) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
21
# File 'lib/user_management_rails.rb', line 12

def self.valid_jwt?(jwt)
  # pub_key = OpenSSL::PKey::RSA.new(ENV['JWT_PUBLIC_KEY'])
  pub_key = OpenSSL::PKey::RSA.new(self.configuration.jwt_public_key)
  begin
    JWT.decode(jwt, pub_key, true, algorithm: 'RS256')[0]
  rescue JWT::DecodeError
    return false
  end
  true
end