Sha256: f549e77302a94cfb8a7ef64b68f54e3216ef2952abb179066346fcfb145f1ee7
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
# Gatleon Rails add authentication to your website - in 1 minute or less. ## Installation Add this line to your application's Gemfile: ```ruby gem "gatleon-rails" ``` And then execute: ``` $ bundle install ``` Add a profile controller ```ruby class ProfileController < ActionController::Base AUTHFORM_FORM_PUBLIC_KEY = "" # Available at https://authform.gatleon.com. coming soon! AUTHFORM_FORM_SECRET_KEY = "" # Available at https://authform.gatleon.com. coming soon! include Gatleon::Rails::Authform::Concern.new(public_key: AUTHFORM_FORM_PUBLIC_KEY, secret_key: AUTHFORM_FORM_SECRET_KEY) before_action :require_login, only: [:index] def index erb = <<~ERB <h1>Profile</h1> <p style="color: green;">You are signed in.</p> <p><%= current_user %></p> ERB render inline: erb end def signin erb = <<~ERB <p style="color: red;"><%= flash[:error] %></p> <h1>Sign In</h1> <form action="https://authform.gatleon.com/v1/form/<%= ProfileController::AUTHFORM_FORM_PUBLIC_KEY %>" method="POST"> <input type="email" name="email"> <button type="submit">Sign In</button> </form> ERB render inline: erb end private def require_login unless current_user flash[:error] = "Sign in, please." redirect_to(profile_signin_path) and return end end end ``` Add profile routes to routes.rb ```ruby Rails.application.routes.draw do get '/profile', to: 'profile#index', as: 'profile' get '/profile/signin', to: 'profile#signin', as: 'profile_signin' end ``` That's it! ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gatleon-rails-0.2.0 | README.md |