README.md in gatleon-rails-0.1.10 vs README.md in gatleon-rails-0.2.0

- old
+ new

@@ -1,40 +1,78 @@ -# Gatleon::Rails +# Gatleon Rails -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gatleon/rails`. To experiment with that code, run `bin/console` for an interactive prompt. +add authentication to your website - in 1 minute or less. -TODO: Delete this and the text above, and describe your gem - ## Installation Add this line to your application's Gemfile: ```ruby -gem 'gatleon-rails' +gem "gatleon-rails" ``` And then execute: - $ bundle install +``` +$ bundle install +``` -Or install it yourself as: +Add a profile controller - $ gem install gatleon-rails +```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! -## Usage + include Gatleon::Rails::Authform::Concern.new(public_key: AUTHFORM_FORM_PUBLIC_KEY, secret_key: AUTHFORM_FORM_SECRET_KEY) -TODO: Write usage instructions here + before_action :require_login, only: [:index] -## Development + def index + erb = <<~ERB + <h1>Profile</h1> + <p style="color: green;">You are signed in.</p> + <p><%= current_user %></p> + ERB -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. + render inline: erb + end -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). + 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 -## Contributing + render inline: erb + end -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gatleon-rails. + 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).