Frontegg Ruby Library

This is a ruby lib that allows to use the Frontegg API

Setup

To install using bundler:

gem 'frontegg', github: 'hinthealth/frontegg'
Frontegg.configure do |config|
  config.client_id = 'your_client_id'
  config.api_key =  'your_api_key'
  config.log_enabled = false
end

Usage

Users

Create user

Frontegg::User.new.create(
  tenant_id:, # required
  email:, # required
  name:, # required
  metadata:,
  password:,
)

Migrate existing user

Frontegg::User.new.migrate_existing(
  tenant_id:, # required
  email:, # required
  name:, # required
  metadata:,
  password_hash:,
  mfa_code:,
)

Add user to tenant

Frontegg::User.new(frontegg_user_id).add_to_tenant(tenant_id)

Switch user tenant

Frontegg::User.new(frontegg_user_id).switch_tenant(tenant_id)

Delete user

Frontegg::User.new(frontegg_user_id).delete(tenant_id:) # tenant is optional

Retrieve user

Frontegg::User.new(frontegg_user_id).retrieve(tenant_id:) # tenant is optional

Make super user

Frontegg::User.new(frontegg_user_id).make_superuser # tenant is optional

Verify user

Frontegg::User.new(frontegg_user_id).verify

Expire sessions

Frontegg::User.new(frontegg_user_id).expire_sessions(session_id) # session_id is optional

Tenants

Create tenant

Frontegg::Tenant.new.create(
  name:,
  website: nil,
  logo_url: nil,
  metadata: {}
)

Update tenant

Frontegg::Tenant.new(frontegg_tenant_id).create(
  name:,
  website: nil,
  logo_url: nil,
  metadata: {}
)

Retrieve tenant

Frontegg::Tenant.new(frontegg_tenant_id).retrieve

Delete tenant

Frontegg::Tenant.new(frontegg_tenant_id).delete

Passwords

Update password

Frontegg::Password.new.update(user_id:, password:, new_password:)

Create reset token

Frontegg::Password.new.create_reset_token(user_id:)

Reset with token

Frontegg::Password.new.reset_with_token(user_id:, token:, password:)

MFAs

Create

Frontegg::Mfa.new.update(user_id:)

Verify

Frontegg::Mfa.new.verify(token, user_id:)

Reset

Frontegg::Mfa.new.reset(user_id:)

Enforce

Frontegg::Mfa.new.enforce(enforce, device_expiration:, tenant_id: nil)