Title: Rails Login
Author: paulrosen
Published: <strong>January 15, 2015</strong>
Last modified: January 15, 2015

---

Search plugins

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://s.w.org/plugins/geopattern-icon/rails-login.svg)

# Rails Login

 By [paulrosen](https://profiles.wordpress.org/paulrosen/)

[Download](https://downloads.wordpress.org/plugin/rails-login.zip)

 * [Details](https://wordpress.org/plugins/rails-login/#description)
 * [Reviews](https://wordpress.org/plugins/rails-login/#reviews)
 *  [Installation](https://wordpress.org/plugins/rails-login/#installation)
 * [Development](https://wordpress.org/plugins/rails-login/#developers)

 [Support](https://wordpress.org/support/plugin/rails-login/)

## Description

If you have set up a WordPress installation as a subfolder of a Rails App, this 
plugin will make your users login with your Rails app. That is, there is no WordPress
login; your users will be logged in if they are logged in to Rails, and they are
not logged in if not.

The WordPress installation needs to be on the same domain as the Rails app because
it needs to access the same cookie.

## Screenshots

[⌊Settings page for administrators.⌉⌊Settings page for administrators.⌉[

Settings page for administrators.

## Installation

 1. Be sure that the Rails side is set up and working. See FAQ for more details.
 2. Unzip this plugin folder and copy the _rails-login_ subfolder to your WordPress’s
    plugin directory.
 3. Activate the plugin through the ‘Plugins’ menu in WordPress.
 4. Configure the settings in the ‘Settings/Rails Login’ page.

## FAQ

#### How should the Rails app be set up?

You must first configure your Rails app and WordPress installation to work together.
For instructions on how to do that, and a possible way to share a theme between 
WordPress and Rails is here: [Rails Theme](https://wordpress.org/plugins/rails-theme/)

In your routes.rb file:

get ‘/authentication/user’ => “authentication#user”

after logging in and logging out, insert this statement:

write_user_cookie()

Add this to authentication_controller.rb:

    ```
    #GET /authentication/user.json def user     user = read_user_cookie(params[:id])     obj = { user: user }     puts obj.to_json()     respond_to do |format|         format.json { render :json => { user: user } }     end end  private  def get_crypt     key = ActiveSupport::KeyGenerator.new(Rails.application.secrets.secret_key_base).generate_key("read-current-user")     crypt = ActiveSupport::MessageEncryptor.new(key)     return crypt end  def write_user_cookie     crypt = get_crypt()     cookie_name = Rails.application.config.session_options[:key] + '2'     id = current_user.present? ? current_user.id : 0     cookies[cookie_name] = crypt.encrypt_and_sign(id) end  def read_user_cookie(cookie)     crypt = get_crypt()     id = crypt.decrypt_and_verify(cookie)      user = User.where(id: id).first     if user.present? && !user.disabled         name = user.first_name + ' ' + user.last_name         return { email: user.email,                  first_name: user.first_name,                  last_name: user.last_name,                  url: '', description: '',                  username: user.email,                  login: user.email,                  nickname: name,                  display_name: name         }     else         return ''     end end 
    ```

## Reviews

There are no reviews for this plugin.

## Contributors & Developers

“Rails Login” is open source software. The following people have contributed to 
this plugin.

Contributors

 *   [ paulrosen ](https://profiles.wordpress.org/paulrosen/)

[Translate “Rails Login” into your language.](https://translate.wordpress.org/projects/wp-plugins/rails-login)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/rails-login/), check
out the [SVN repository](https://plugins.svn.wordpress.org/rails-login/), or subscribe
to the [development log](https://plugins.trac.wordpress.org/log/rails-login/) by
[RSS](https://plugins.trac.wordpress.org/log/rails-login/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.0.0

 * Initial release.

## Meta

 *  Version **1.0**
 *  Last updated **12 years ago**
 *  Active installations **Fewer than 10**
 *  WordPress version ** 4.0.0 or higher **
 *  Tested up to **4.1.0**
 * Tags
 * [authentication](https://wordpress.org/plugins/tags/authentication/)[login](https://wordpress.org/plugins/tags/login/)
   [rails](https://wordpress.org/plugins/tags/rails/)
 *  [Advanced View](https://wordpress.org/plugins/rails-login/advanced/)

## Ratings

No reviews have been submitted yet.

[Your review](https://wordpress.org/support/plugin/rails-login/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/rails-login/reviews/)

## Contributors

 *   [ paulrosen ](https://profiles.wordpress.org/paulrosen/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/rails-login/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](http://paulrosen.net/rails_login)