{"id":33939,"date":"2015-01-15T16:31:11","date_gmt":"2015-01-15T16:31:11","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/rails-login\/"},"modified":"2015-01-15T16:31:11","modified_gmt":"2015-01-15T16:31:11","slug":"rails-login","status":"publish","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/rails-login\/","author":8573476,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0","stable_tag":"trunk","tested":"4.1.0","requires":"4.0.0","requires_php":"","requires_plugins":"","header_name":"Rails Login","header_author":"Paul Rosen","header_description":"","assets_banners_color":"","last_updated":"2015-01-15 16:31:11","external_support_url":"","external_repository_url":"","donate_link":"http:\/\/paulrosen.net\/rails_login","header_plugin_uri":"http:\/\/wordpress.paulrosen.net\/rails_login","header_author_uri":"http:\/\/wordpress.paulrosen.net","rating":0,"author_block_rating":0,"active_installs":0,"downloads":1183,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":0},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":{"screenshot-1.jpg":{"filename":"screenshot-1.jpg","revision":"1444288","resolution":"1","location":"plugin","width":909,"height":865}},"screenshots":{"1":"Settings page for administrators."}},"plugin_section":[],"plugin_tags":[710,602,52254],"plugin_category":[38],"plugin_contributors":[],"plugin_business_model":[],"class_list":["post-33939","plugin","type-plugin","status-publish","hentry","plugin_tags-authentication","plugin_tags-login","plugin_tags-rails","plugin_category-authentication","plugin_committers-paulrosen"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/rails-login.svg","icon_2x":false,"generated":true},"screenshots":[{"src":"https:\/\/ps.w.org\/rails-login\/trunk\/screenshot-1.jpg?rev=1444288","caption":"Settings page for administrators."}],"raw_content":"<!--section=description-->\n<p>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.<\/p>\n <p>The WordPress installation needs to be on the same domain as the Rails app because it needs to access the same cookie.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Be sure that the Rails side is set up and working. See FAQ for more details.<\/li>\n<li>Unzip this plugin folder and copy the <em>rails-login<\/em> subfolder to your WordPress's plugin directory.<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress.<\/li>\n<li>Configure the settings in the 'Settings\/Rails Login' page.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<h4>How should the Rails app be set up?<\/h4>\n <p>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: <a href=\"https:\/\/wordpress.org\/plugins\/rails-theme\/\">Rails Theme<\/a><\/p>\n <p>In your routes.rb file:<\/p>\n <p>get '\/authentication\/user' =&gt; \"authentication#user\"<\/p>\n <p>after logging in and logging out, insert this statement:<\/p>\n <p>write_user_cookie()<\/p>\n <p>Add this to authentication_controller.rb:<\/p>\n <pre><code>#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 =&gt; { 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? &amp;&amp; !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 <\/code><\/pre>\n\n<!--section=changelog-->\n<h4>1.0.0<\/h4>\n <ul>\n<li>Initial release.<\/li>\n<\/ul>","raw_excerpt":"The Rails Login plugin enables a WordPress installation that is in a subfolder of a Rails application to use the Rails authentication instead of its o &hellip;","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/33939","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=33939"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/paulrosen"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=33939"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=33939"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=33939"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=33939"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=33939"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=33939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}