better_authy 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cd343402586a23dd2212844efaa3a7007be3a0777b5012264d9380852b060c8
4
- data.tar.gz: b0bde974d6e6c64172d8453193fe4c0727cd3d101b9548093928ab7a33259a0d
3
+ metadata.gz: 2693e675abcb3ae3c4644e289aae00407020371666dd7c2e8753467251b58578
4
+ data.tar.gz: 02fa828bcb116d82ecdf8160fa2adc221217c9902b03034d2c4322644504d0f7
5
5
  SHA512:
6
- metadata.gz: 7f58ca868ea2d945e6f2ec0e22b4c255295efa4354a277648c32d9547d3525e8515f705d595a0c4671225cdf77e4ae070891832dfb96fb1d95fefce52a267b94
7
- data.tar.gz: df65aa3eb2b1afb41e9c386d92e045e8f9deb3763c512d5d381d9e7256becefc1dcfe8a08fb16a8671fbfa12bf995948096e04b0c6816eb9ce30abee277ea50a
6
+ metadata.gz: 2ed512366330a01ea77e91e69521c44514144cd1784b7a93534276e9a5938156ac8b48bcbd77033e748349fa2d22e33937c52a10dcbd6ed9f6c238b7a9f5cf24
7
+ data.tar.gz: 6ea42213032ced5d1ffe35280fea43d68e6e6463b8ed0529090742045b056993cbf418e2464fd8d4f427dbf2fdc371ec3d71195e3d5b544532751f8abfbb1970
data/README.md CHANGED
@@ -15,7 +15,7 @@ A flexible authentication engine for Rails 8.0+ with multi-scope support. Enable
15
15
  ### 1. Add to Gemfile
16
16
 
17
17
  ```ruby
18
- gem "better_authy", "~> 0.1.0"
18
+ gem "better_authy", "~> 0.2.0"
19
19
  ```
20
20
 
21
21
  ### 2. Configure scope
@@ -3,6 +3,7 @@
3
3
  module BetterAuthy
4
4
  class BaseController < ::ApplicationController
5
5
  helper BetterAuthy::ApplicationHelper
6
+ helper_method :scope_config
6
7
 
7
8
  layout :resolve_layout
8
9
  protect_from_forgery with: :exception
@@ -2,6 +2,7 @@
2
2
 
3
3
  module BetterAuthy
4
4
  class RegistrationsController < BaseController
5
+ before_action :ensure_sign_up_enabled
5
6
  before_action :redirect_if_signed_in, only: %i[new create]
6
7
 
7
8
  def new
@@ -20,6 +21,12 @@ module BetterAuthy
20
21
 
21
22
  private
22
23
 
24
+ def ensure_sign_up_enabled
25
+ return if scope_config.sign_up_enabled?
26
+
27
+ raise ActionController::RoutingError, "Not Found"
28
+ end
29
+
23
30
  def resource_params
24
31
  params.require(scope_name).permit(:email, :password, :password_confirmation)
25
32
  end
@@ -68,13 +68,15 @@
68
68
  <% end %>
69
69
  <% end %>
70
70
 
71
- <% card.with_footer do %>
72
- <p class="text-center text-sm text-grayscale-600">
73
- <%= t("better_authy.sessions.no_account") %>
74
- <%= link_to t("better_authy.sessions.signup_link"),
75
- send(:"#{params[:scope]}_signup_path"),
76
- class: "font-medium text-primary-600 hover:text-primary-500" %>
77
- </p>
71
+ <% if scope_config.sign_up_enabled? %>
72
+ <% card.with_footer do %>
73
+ <p class="text-center text-sm text-grayscale-600">
74
+ <%= t("better_authy.sessions.no_account") %>
75
+ <%= link_to t("better_authy.sessions.signup_link"),
76
+ send(:"#{params[:scope]}_signup_path"),
77
+ class: "font-medium text-primary-600 hover:text-primary-500" %>
78
+ </p>
79
+ <% end %>
78
80
  <% end %>
79
81
  <% end %>
80
82
  </div>
@@ -4,7 +4,8 @@ module BetterAuthy
4
4
  class ScopeConfiguration
5
5
  attr_reader :name
6
6
  attr_accessor :model_name, :session_key, :remember_cookie, :remember_for,
7
- :sign_in_path, :after_sign_in_path, :layout, :password_reset_within
7
+ :sign_in_path, :after_sign_in_path, :layout, :password_reset_within,
8
+ :enable_sign_up
8
9
 
9
10
  def initialize(name)
10
11
  @name = name.to_sym
@@ -15,6 +16,11 @@ module BetterAuthy
15
16
  @sign_in_path = "/auth/#{name}/login"
16
17
  @after_sign_in_path = "/"
17
18
  @layout = "better_authy/application"
19
+ @enable_sign_up = true
20
+ end
21
+
22
+ def sign_up_enabled?
23
+ @enable_sign_up
18
24
  end
19
25
 
20
26
  def model_class
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BetterAuthy
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_authy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Umberto Peserico