trestle-auth 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of trestle-auth might be problematic. Click here for more details.

Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.browserslistrc +0 -1
  3. data/.gitignore +4 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +20 -3
  6. data/Gemfile +14 -0
  7. data/README.md +34 -7
  8. data/app/assets/bundle/trestle/auth/bundle.css +1 -1
  9. data/app/assets/bundle/trestle/auth/userbox.css +1 -1
  10. data/app/controllers/trestle/auth/sessions_controller.rb +3 -4
  11. data/app/views/trestle/auth/_userbox.html.erb +16 -4
  12. data/app/views/trestle/auth/sessions/_form.html.erb +32 -0
  13. data/app/views/trestle/auth/sessions/new.html.erb +2 -33
  14. data/bin/rails +20 -0
  15. data/config/routes.rb +8 -3
  16. data/frontend/userbox.scss +4 -0
  17. data/gemfiles/rails-4.2.gemfile +18 -0
  18. data/gemfiles/rails-5.0.gemfile +18 -0
  19. data/gemfiles/rails-5.1.gemfile +18 -0
  20. data/gemfiles/rails-5.2.gemfile +18 -0
  21. data/gemfiles/rails-6.0.gemfile +18 -0
  22. data/lib/generators/trestle/auth/admin/admin_generator.rb +6 -0
  23. data/lib/generators/trestle/auth/admin/templates/admin.rb.erb +22 -1
  24. data/lib/generators/trestle/auth/install/install_generator.rb +30 -118
  25. data/lib/generators/trestle/auth/install/templates/basic.rb.erb +121 -0
  26. data/lib/generators/trestle/auth/install/templates/devise.rb.erb +87 -0
  27. data/lib/trestle/auth.rb +14 -8
  28. data/lib/trestle/auth/backends.rb +34 -0
  29. data/lib/trestle/auth/backends/base.rb +28 -0
  30. data/lib/trestle/auth/backends/basic.rb +72 -0
  31. data/lib/trestle/auth/backends/devise.rb +14 -0
  32. data/lib/trestle/auth/backends/warden.rb +53 -0
  33. data/lib/trestle/auth/configuration.rb +25 -3
  34. data/lib/trestle/auth/configuration/warden.rb +11 -0
  35. data/lib/trestle/auth/controller/authentication.rb +55 -0
  36. data/lib/trestle/auth/controller/locale.rb +18 -0
  37. data/lib/trestle/auth/controller/time_zone.rb +18 -0
  38. data/lib/trestle/auth/controller_methods.rb +3 -74
  39. data/lib/trestle/auth/model_methods.rb +2 -3
  40. data/lib/trestle/auth/version.rb +1 -1
  41. data/trestle-auth.gemspec +13 -9
  42. data/yarn.lock +584 -452
  43. metadata +34 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c66ad14a57d22f21b9e9b170a48a505060704b557c0abde4e56526f1b7d95561
4
- data.tar.gz: b8d449820f15f9923724d58650f965715cf420073d52d52d4353e20f6de14068
3
+ metadata.gz: 464d95c8de9173fe65265a2c9721c6da23b78fbf49e566a5b148b68ddd534ed1
4
+ data.tar.gz: b016d91dedc61d8bd1213137f6118b13a28a099f383ca002496101ea3d001722
5
5
  SHA512:
6
- metadata.gz: d58fe42ceab549559ffa679ef6e028695c27d815e4958278300a0de0ff943ff0f8480519e3bfd1cd59fac6e3763afdfa3829dc31c8d6475018f7ef8c21d4e738
7
- data.tar.gz: af0149b4c92cad0b37bf42f82369507a2d3a57c46a8ed116ef2781965a7b837688c7a7fd0c50fd0087493b39b74266d0ba062a2e25c700747c47b4730591a835
6
+ metadata.gz: 88d8a60ce5d4a8a2e8fdec285706ae5fa45212cc81db6b75970ee92e8b1013665e05884adb921967319a3942c374b46a54eed434a14c81e0cecb01a3d426e9e3
7
+ data.tar.gz: a0ee867bde142a6580ce2ecd89afe1a68f21335d133bf6442c076dd3d6f98652803d20a27047df7c5a7c8384ce252f055ff0fc10909ecc6a6bc9f5e6ba9e4450
@@ -1,2 +1 @@
1
1
  > 0.25%
2
-
data/.gitignore CHANGED
@@ -8,3 +8,7 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /node_modules/
11
+ /spec/dummy/db/*.sqlite3
12
+ /spec/dummy/*.sqlite3-journal
13
+ /spec/dummy/log/*.log
14
+ /spec/dummy/tmp/*
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
+ --require spec_helper
1
2
  --format documentation
2
3
  --color
@@ -1,5 +1,22 @@
1
- sudo: false
2
1
  language: ruby
2
+
3
+ cache: bundler
4
+
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
8
+
3
9
  rvm:
4
- - 2.3.1
5
- before_install: gem install bundler -v 1.12.5
10
+ - 2.6.5
11
+
12
+ gemfile:
13
+ - gemfiles/rails-5.0.gemfile
14
+ - gemfiles/rails-5.1.gemfile
15
+ - gemfiles/rails-5.2.gemfile
16
+ - gemfiles/rails-6.0.gemfile
17
+
18
+ jobs:
19
+ include:
20
+ gemfile: gemfiles/rails-4.2.gemfile
21
+ before_install:
22
+ - gem install bundler -v '< 2'
data/Gemfile CHANGED
@@ -2,3 +2,17 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in trestle-auth.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem "coveralls", require: false
8
+
9
+ gem "capybara"
10
+ gem "sqlite3", "~> 1.4"
11
+ gem "devise"
12
+ end
13
+
14
+ gem "sassc-rails"
15
+
16
+ gem "rake", "~> 12.0"
17
+
18
+ gem "trestle", github: "TrestleAdmin/trestle"
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Trestle Authentication (trestle-auth)
2
2
 
3
+ [![RubyGem](https://img.shields.io/gem/v/trestle-auth.svg?style=flat&colorB=4065a9)](https://rubygems.org/gems/trestle-auth)
4
+ [![Travis](https://img.shields.io/travis/TrestleAdmin/trestle-auth.svg?style=flat)](https://travis-ci.org/TrestleAdmin/trestle-auth)
5
+ [![Coveralls](https://img.shields.io/coveralls/TrestleAdmin/trestle-auth.svg?style=flat)](https://coveralls.io/github/TrestleAdmin/trestle-auth)
6
+
3
7
  > Authentication plugin for the Trestle admin framework
4
8
 
5
9
  <img src="https://trestle.io/images/Trestle-Auth-1.png" width="50%" /><img src="https://trestle.io/images/Trestle-Auth-2.png" width="50%" />
@@ -7,25 +11,48 @@
7
11
 
8
12
  ## Getting Started
9
13
 
10
- These instructions assume you have a working Trestle application. To integrate trestle-auth, first add it to your application's Gemfile:
14
+ These instructions assume you have a working Trestle application. See the [Getting Started](https://github.com/TrestleAdmin/trestle#getting-started) section in the Trestle README.
15
+
16
+ To integrate trestle-auth, first add it to your application's Gemfile, and then run `bundle install`:
11
17
 
12
18
  ```ruby
13
19
  gem 'trestle-auth'
14
20
  ```
15
21
 
16
- Run `bundle install`, and then run the install generator to set up configuration options, user model and user admin resource.
22
+ As of version 0.4.0, trestle-auth now supports multiple authentication backends including Devise/Warden.
23
+
24
+
25
+ ### Option 1: Built-in Integration
17
26
 
18
- $ rails generate trestle:auth:install
19
- $ rake db:migrate
27
+ Run the install generator to add the configuration to `config/initializers/trestle.rb`, and generate a `User` model and admin resource.
20
28
 
21
- Then create an initial admin user from the rails console:
29
+ $ rails generate trestle:auth:install User
22
30
 
23
- $ rails console
24
- > Administrator.create(email: "admin@example.com", password: "password", first_name: "Admin", last_name: "User")
31
+ (if no user model name is specified it will default to `Administrator`)
32
+
33
+ Then run your migrations with `rake db:migrate` and create an initial admin user from within `rails console`:
34
+
35
+ ```ruby
36
+ User.create(email: "admin@example.com", password: "password", first_name: "Admin", last_name: "User")
37
+ ```
25
38
 
26
39
  After restarting your Rails server, any attempt to access a page within your admin will redirect you to the login page.
27
40
 
28
41
 
42
+ ### Option 2: Devise Integration
43
+
44
+ If you already have an existing user model and Devise integration, you can configure trestle-auth to use that instead.
45
+
46
+ $ rails generate trestle:auth:install User --devise
47
+
48
+ Replace `User` with the name of your Devise user model. If not specified, it will default to `Administrator`.
49
+
50
+
51
+ ## Configuration
52
+
53
+ After running the `trestle:auth:install` generator, check your `config/initializers/trestle.rb` for further configuration options.
54
+
55
+
29
56
  ## License
30
57
 
31
58
  The gem is available as open source under the terms of the [LGPLv3 License](https://opensource.org/licenses/LGPL-3.0).
@@ -1 +1 @@
1
- .auth-body{display:-webkit-box;display:flex;color:#fff}.auth-body .container{margin:auto;width:320px}.auth-header{text-align:center;margin-bottom:20px}.auth-header h1{display:-webkit-box;display:flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;font-size:1.75rem;font-weight:500;text-shadow:rgba(0,0,0,.5) 0 1px 1px;padding:.75rem 1rem}.auth-header img{max-width:80%;max-height:100%}.auth-header span{margin-left:10px}.login-form .form-control,.login-form .input-group-text{background:hsla(0,0%,100%,.1);border:0}.login-form .form-control{color:#fff;font-size:1.1rem;padding:1.75rem .75rem}.login-form .form-control:focus{outline-color:transparent;outline-style:none;box-shadow:none}.login-form .form-control::-webkit-input-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control::-moz-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control:-ms-input-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control::-ms-input-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control::placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control:-webkit-autofill{-webkit-text-fill-color:#fff}.login-form .form-control:-webkit-autofill,.login-form .form-control:-webkit-autofill:active,.login-form .form-control:-webkit-autofill:focus,.login-form .form-control:-webkit-autofill:hover{-webkit-transition:background-color 9999999s ease-in-out 0s;transition:background-color 9999999s ease-in-out 0s}.login-form .input-group-prepend{margin-right:0}.login-form .input-group-text{color:hsla(0,0%,100%,.5);padding:.375rem .25rem .375rem 1rem}.login-form .btn-primary{box-shadow:0 0 2px rgba(0,0,0,.1);padding-top:.75rem;padding-bottom:.75rem}.login-form .alert-danger{background-color:rgba(222,116,113,.75)}.login-form .remember-me{font-size:.95rem;line-height:1.5;padding-left:0}.login-form .remember-me .custom-control-label{display:block;cursor:pointer;background:rgba(0,0,0,.075);color:hsla(0,0%,100%,.75);border-radius:.25rem;padding:.75em 1.5em .75em 3.25em}.login-form .remember-me .custom-control-label:hover{background:rgba(0,0,0,.125)}.login-form .remember-me .custom-control-label:after,.login-form .remember-me .custom-control-label:before{top:.925em;left:1.1em}
1
+ .auth-body{display:flex;color:#fff}.auth-body .container{margin:auto;width:320px}.auth-header{text-align:center;margin-bottom:20px}.auth-header h1{display:flex;align-items:center;justify-content:center;font-size:1.75rem;font-weight:500;text-shadow:rgba(0,0,0,.5) 0 1px 1px;padding:.75rem 1rem}.auth-header img{max-width:80%;max-height:100%}.auth-header span{margin-left:10px}.login-form .form-control,.login-form .input-group-text{background:hsla(0,0%,100%,.1);border:0}.login-form .form-control{color:#fff;font-size:1.1rem;padding:1.75rem .75rem}.login-form .form-control:focus{outline-color:transparent;outline-style:none;box-shadow:none}.login-form .form-control::-webkit-input-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control:-ms-input-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control::-ms-input-placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control::placeholder{color:hsla(0,0%,100%,.5)}.login-form .form-control:-webkit-autofill{-webkit-text-fill-color:#fff}.login-form .form-control:-webkit-autofill,.login-form .form-control:-webkit-autofill:active,.login-form .form-control:-webkit-autofill:focus,.login-form .form-control:-webkit-autofill:hover{-webkit-transition:background-color 9999999s ease-in-out 0s;transition:background-color 9999999s ease-in-out 0s}.login-form .input-group-prepend{margin-right:0}.login-form .input-group-text{color:hsla(0,0%,100%,.5);padding:.375rem .25rem .375rem 1rem}.login-form .btn-primary{box-shadow:0 0 2px rgba(0,0,0,.1);padding-top:.75rem;padding-bottom:.75rem}.login-form .alert-danger{background-color:rgba(222,116,113,.75)}.login-form .remember-me{font-size:.95rem;line-height:1.5;padding-left:0}.login-form .remember-me .custom-control-label{display:block;cursor:pointer;background:rgba(0,0,0,.075);color:hsla(0,0%,100%,.75);border-radius:.25rem;padding:.75em 1.5em .75em 3.25em}.login-form .remember-me .custom-control-label:hover{background:rgba(0,0,0,.125)}.login-form .remember-me .custom-control-label:after,.login-form .remember-me .custom-control-label:before{top:.925em;left:1.1em}
@@ -1 +1 @@
1
- .userbox{-webkit-box-ordinal-group:100;order:99;padding:2px 0}.userbox>a{color:#333;display:block;padding:2px 0;font-weight:400;line-height:40px}.userbox>a:focus,.userbox>a:hover{text-decoration:none}.userbox .avatar{vertical-align:top;margin-left:6px}.userbox .dropdown-toggle:after{vertical-align:middle}@media (max-width:767.98px){.userbox{display:block;position:relative;z-index:5}.userbox .name{display:none}.userbox .avatar{border:1px solid hsla(0,0%,100%,.25)}}
1
+ .userbox{order:99;padding:2px 0;display:flex;align-items:center}.userbox>a{color:#333;display:block;padding:2px 0;font-weight:400;line-height:40px}.userbox>a:focus,.userbox>a:hover{text-decoration:none}.userbox .avatar{vertical-align:top;margin-left:6px}.userbox .dropdown-toggle:after{vertical-align:middle}@media (max-width:767.98px){.userbox{display:block;position:relative;z-index:5}.userbox .name{display:none}.userbox .avatar{border:1px solid hsla(0,0%,100%,.25);margin-left:0}}
@@ -1,16 +1,15 @@
1
1
  class Trestle::Auth::SessionsController < Trestle::ApplicationController
2
2
  layout 'trestle/auth'
3
3
 
4
+ skip_before_action :authenticate_user, only: [:new, :create]
4
5
  skip_before_action :require_authenticated_user
5
6
 
6
7
  def new
7
8
  end
8
9
 
9
10
  def create
10
- if user = Trestle.config.auth.authenticate(params)
11
- login!(user)
12
- remember_me! if params[:remember_me] == "1"
13
- redirect_to previous_location || instance_exec(&Trestle.config.auth.redirect_on_login)
11
+ if authentication_backend.authenticate!
12
+ redirect_to authentication_backend.previous_location || instance_exec(&Trestle.config.auth.redirect_on_login)
14
13
  else
15
14
  flash[:error] = t("admin.auth.error", default: "Incorrect login details.")
16
15
  redirect_to action: :new
@@ -1,16 +1,28 @@
1
- <div class="userbox dropdown">
2
- <%= link_to "#", data: { toggle: 'dropdown' } do %>
3
- <span class="name dropdown-toggle">
1
+ <% show_dropdown = (Trestle.config.auth.user_admin && Trestle.lookup(Trestle.config.auth.user_admin)) || Trestle.config.auth.enable_logout %>
2
+
3
+ <div class="userbox<% if show_dropdown %> dropdown<% end %>">
4
+ <% content = capture do %>
5
+ <span class="name<% if show_dropdown %> dropdown-toggle<% end %>">
4
6
  <%= format_user_name(current_user) %>
5
7
  </span>
6
8
 
7
9
  <%= avatar_for(current_user) %>
8
10
  <% end %>
9
11
 
12
+ <% if show_dropdown %>
13
+ <%= link_to content, "#", data: { toggle: 'dropdown' } %>
14
+ <% else %>
15
+ <%= content %>
16
+ <% end %>
17
+
18
+ <% if show_dropdown -%>
10
19
  <ul class="dropdown-menu dropdown-menu-right">
11
20
  <% if Trestle.config.auth.user_admin && user_admin = Trestle.lookup(Trestle.config.auth.user_admin) -%>
12
21
  <li><%= admin_link_to t("admin.auth.my_account", default: "My Account"), current_user, admin: user_admin, class: "dropdown-item" %></li>
13
22
  <% end -%>
14
- <li><%= link_to t("admin.auth.logout", default: "Log out"), trestle.logout_path, class: "dropdown-item" %></li>
23
+ <% if Trestle.config.auth.enable_logout -%>
24
+ <li><%= link_to t("admin.auth.logout", default: "Log out"), trestle.logout_path, class: "dropdown-item" %></li>
25
+ <% end -%>
15
26
  </ul>
27
+ <% end %>
16
28
  </div>
@@ -0,0 +1,32 @@
1
+ <div class="form-group">
2
+ <div class="input-group">
3
+ <div class="input-group-prepend">
4
+ <span class="input-group-text"><i class="fa fa-user fa-fw"></i></span>
5
+ </div>
6
+ <%= f.text_field Trestle.config.auth.authenticate_with, placeholder: Trestle.config.auth.human_attribute_name(Trestle.config.auth.authenticate_with), class: "form-control" %>
7
+ </div>
8
+ </div>
9
+
10
+ <div class="form-group">
11
+ <div class="input-group">
12
+ <div class="input-group-prepend">
13
+ <span class="input-group-text"><i class="fa fa-lock fa-fw"></i></span>
14
+ </div>
15
+ <%= f.password_field :password, placeholder: Trestle.config.auth.human_attribute_name(:password), class: "form-control" %>
16
+ </div>
17
+ </div>
18
+
19
+ <%= hook("auth.login.form") %>
20
+
21
+ <% if Trestle.config.auth.remember.enabled %>
22
+ <div class="form-group">
23
+ <div class="custom-control custom-checkbox remember-me">
24
+ <%= f.check_box :remember_me, class: "custom-control-input", include_hidden: false %>
25
+ <%= f.label :remember_me, t("admin.auth.remember_me", default: "Remember me"), class: "custom-control-label" %>
26
+ </div>
27
+ </div>
28
+ <% end %>
29
+
30
+ <div class="form-group">
31
+ <%= f.submit t("admin.auth.login", default: "Login"), class: "btn btn-primary btn-block btn-lg" %>
32
+ </div>
@@ -1,4 +1,4 @@
1
- <%= form_tag login_path, class: "login-form" do %>
1
+ <%= form_for authentication_scope, url: login_path, html: { class: "login-form" } do |f| %>
2
2
  <header class="auth-header">
3
3
  <%= hook("auth.login.heading") do %>
4
4
  <h1><%= trestle_auth_title %></h1>
@@ -11,36 +11,5 @@
11
11
  </div>
12
12
  <% end -%>
13
13
 
14
- <div class="form-group">
15
- <div class="input-group">
16
- <div class="input-group-prepend">
17
- <span class="input-group-text"><i class="fa fa-user fa-fw"></i></span>
18
- </div>
19
- <%= text_field_tag Trestle.config.auth.authenticate_with, "", placeholder: Trestle.config.auth.authenticate_with.to_s.humanize, class: "form-control" %>
20
- </div>
21
- </div>
22
-
23
- <div class="form-group">
24
- <div class="input-group">
25
- <div class="input-group-prepend">
26
- <span class="input-group-text"><i class="fa fa-lock fa-fw"></i></span>
27
- </div>
28
- <%= password_field_tag :password, "", placeholder: "Password", class: "form-control" %>
29
- </div>
30
- </div>
31
-
32
- <%= hook("auth.login.form") %>
33
-
34
- <% if Trestle.config.auth.remember.enabled %>
35
- <div class="form-group">
36
- <div class="custom-control custom-checkbox remember-me">
37
- <%= check_box_tag :remember_me, "1", false, class: "custom-control-input" %>
38
- <%= label_tag :remember_me, t("admin.auth.remember_me", default: "Remember me"), class: "custom-control-label" %>
39
- </div>
40
- </div>
41
- <% end %>
42
-
43
- <div class="form-group">
44
- <%= submit_tag t("admin.auth.login", default: "Login"), class: "btn btn-primary btn-block btn-lg" %>
45
- </div>
14
+ <%= render "form", f: f %>
46
15
  <% end %>
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('..', __dir__)
6
+ ENGINE_PATH = File.expand_path('../lib/trestle/auth/engine', __dir__)
7
+
8
+ # Set up gems listed in the Gemfile.
9
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
+
12
+ require "rails"
13
+ # Pick the frameworks you want:
14
+ require "active_model/railtie"
15
+ require "active_record/railtie"
16
+ require "action_controller/railtie"
17
+ require "action_view/railtie"
18
+ require "sprockets/railtie"
19
+ # require "rails/test_unit/railtie"
20
+ require 'rails/engine/commands'
@@ -1,7 +1,12 @@
1
1
  Trestle::Engine.routes.draw do
2
2
  controller "trestle/auth/sessions" do
3
- get 'login' => :new, as: :login
4
- post 'login' => :create
5
- get 'logout' => :destroy, as: :logout
3
+ if Trestle.config.auth.enable_login
4
+ get 'login' => :new, as: :login
5
+ post 'login' => :create
6
+ end
7
+
8
+ if Trestle.config.auth.enable_logout
9
+ get 'logout' => :destroy, as: :logout
10
+ end
6
11
  end
7
12
  end
@@ -4,6 +4,9 @@
4
4
  order: 99;
5
5
  padding: 2px 0;
6
6
 
7
+ display: flex;
8
+ align-items: center;
9
+
7
10
  > a {
8
11
  color: $body-color;
9
12
 
@@ -42,6 +45,7 @@
42
45
 
43
46
  .avatar {
44
47
  border: 1px solid rgba(white, 0.25);
48
+ margin-left: 0;
45
49
  }
46
50
  }
47
51
  }
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+ gem "capybara"
6
+
7
+ gem "sqlite3", "~> 1.3.13"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 4.2.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+ gem "capybara"
6
+
7
+ gem "sqlite3", "~> 1.3.13"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 5.0.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+ gem "capybara"
6
+
7
+ gem "sqlite3", "~> 1.3.13"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 5.1.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+ gem "capybara"
6
+
7
+ gem "sqlite3", "~> 1.3.13"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 5.2.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -0,0 +1,18 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem "coveralls", require: false
5
+
6
+ gem "capybara"
7
+ gem "sqlite3", "~> 1.4"
8
+ gem "devise"
9
+ end
10
+
11
+ gem "rails", "~> 6.0.0"
12
+ gem "sassc-rails"
13
+
14
+ gem "rake", "~> 12.0"
15
+
16
+ gem "trestle", github: "TrestleAdmin/trestle"
17
+
18
+ gemspec path: "../"
@@ -6,12 +6,18 @@ module Trestle
6
6
 
7
7
  argument :model, type: :string, default: "Administrator"
8
8
 
9
+ class_option :devise, type: :boolean, default: false, desc: "Create admin for a Devise user model"
10
+
9
11
  source_root File.expand_path("../templates", __FILE__)
10
12
 
11
13
  def create_admin
12
14
  template "admin.rb.erb", File.join('app/admin/auth', "#{model.underscore.pluralize}_admin.rb")
13
15
  end
14
16
 
17
+ def devise?
18
+ options[:devise]
19
+ end
20
+
15
21
  protected
16
22
  def plural_name
17
23
  model.demodulize.underscore.pluralize