The currentuser-services gem lets you integrate your application with Currentuser.io very easily.

Tip! Currentuser.io is only available for Ruby on Rails for now.

Installation Gem Version

You can install the gem with the two following steps.

1. Add the gem in the Gemfile of your application:

# Gemfile
gem 'currentuser-services'

Then don't forget to execute bundle install.

2. Mount the Currentuser engine by calling 'currentuser' in your routes file:

# config/routes.rb
MyApplication::Application.routes.draw do
  currentuser
end

The command currentuser adds the following routes in your application:

# This always responds with HTTP status 200
GET /currentuser
# This request signs a given user in
GET /currentuser/sign_in
# This request signs current user out
DELETE /currentuser/sign_out
Note that you don't have to use any of these routes directly. Please refer to the Authentication page to learn how to let your users sign in and out.

Configuration

To configure the gem properly, you need to create an initializer in your application:

# config/initializers/currentuser.rb
Currentuser::Services.configure do |config|
  # Replace 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' with your Project ID
  config.project_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
end

To obtain a Project ID, Sign up to Currentuser.io, create a new project and retrieve Project ID from the Currentuser.io settings.