authentication_with_registration_generator 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: 4681439bb93e7104bd2fb5e81beb6d3bdebe2fa7b3f41ab40bf1667d1ec95560
4
- data.tar.gz: 528b29f802154e3d896ba1a9c8a96cf3d7e2d8b7f406a774040050e5503ee962
3
+ metadata.gz: c59c452f38de77479a1aa84069795c21d54bab18dd4926074f9b09c601eeb44d
4
+ data.tar.gz: 44ec7524e8fe23f274e4b25747e802ac73df0171a10ac541e73417dca0a0b2ca
5
5
  SHA512:
6
- metadata.gz: 8e1b97b25be5535e159020308bc0592d97e574b23074f77f7b750f973966e58303f114ac1e43f77dfc419f224017ac9b99072c0d9965ab2aa02d037919f1d565
7
- data.tar.gz: 3684fb7b2a2dd034464294b7c6edb0884a01e0d4d55ac60f06ed9f2a929eb49e6d7a9c8cbc2a2582d62159d514de2ba8037834e895625fa3a311073a90992cae
6
+ metadata.gz: 7bf07f1603f84c47bf10c8fe33fb3ecf3c7362ecc8a7023372ed0f5e5a3875e0fd6f6db17c7c9a488c86068067b1dffe8f73d83a1050424d88fb32dbfe8b4179
7
+ data.tar.gz: 26f4c341ed7a476c9250dff0375bbdbebda1c6fe33db33975dc443e8f023977c33169bdd971249f9e55c3c055fa209a518bc2d19b1e5207b78bebbc4e7b880d2
@@ -16,10 +16,6 @@ module AuthenticationWithRegistration
16
16
  template "registration_form.html.erb", "app/views/registrations/new.html.erb"
17
17
  end
18
18
 
19
- def create_sign_in
20
- template "sign_in_form.html.erb", "app/views/sessions/new.html.erb", force: true
21
- end
22
-
23
19
  def create_controller
24
20
  template "registrations_controller.rb", "app/controllers/registrations_controller.rb"
25
21
  end
@@ -29,6 +25,22 @@ module AuthenticationWithRegistration
29
25
  route "get \"sign_in\", to: \"sessions#new\", as: :sign_in"
30
26
  route "delete \"sign_out\", to: \"sessions#destroy\", as: :sign_out"
31
27
  end
28
+
29
+ def modify_session_view
30
+ # Path to the generated sessions/new.html.erb
31
+ session_view_path = "app/views/sessions/new.html.erb"
32
+
33
+ # Check if the file exists before modifying it
34
+ if File.exists?(session_view_path)
35
+ # Replace the "Forgot password?" link with the new links
36
+ gsub_file session_view_path, /<br>\s*<%= link_to "Forgot password\?", new_password_path %>/ do |match|
37
+ "<p>\n <%= link_to 'Forgot password?', new_password_path %> | \n <%= link_to 'No Account? Register here', new_registration_path %>\n</p>"
38
+ end
39
+ else
40
+ # If the file doesn't exist, handle it accordingly (e.g., raise an error or create the file)
41
+ raise "Session view file not found"
42
+ end
43
+ end
32
44
 
33
45
  def update_authentication_concern
34
46
  inject_into_file "app/controllers/concerns/authentication.rb", before: "private\n" do
@@ -36,22 +48,30 @@ module AuthenticationWithRegistration
36
48
 
37
49
  def link_to_sign_in_or_out
38
50
  if authenticated?
39
- button_to "Sign Out", sign_out_path, method: :delete
51
+ authenticity_token = form_authenticity_token
52
+ action_url = sign_out_path
53
+ # Return the form as a string
54
+ "<form class=\"button_to\" action=\"#{action_url}\" accept-charset=\"UTF-8\" method=\"post\">
55
+ <input type=\"hidden\" name=\"_method\" value=\"delete\" autocomplete=\"off\" />
56
+ <button type=\"submit\">Sign Out</button>
57
+ <input type=\"hidden\" name=\"authenticity_token\" value=\"#{authenticity_token}\" autocomplete=\"off\" />
58
+ </form>".html_safe
40
59
  else
41
- link_to "Sign In", sign_in_path
60
+ "<a href=\"#{sign_in_path}\">Sign In</a>".html_safe
42
61
  end
43
- end
62
+ end
44
63
 
45
64
  def show_user_if_signed_in
46
65
  if authenticated?
47
66
  "Signed in as \#{Current.user.email_address}"
48
67
  end
49
68
  end
69
+
50
70
  RUBY
51
71
  end
52
72
 
53
- inject_into_file "app/controllers/concerns/authentication.rb", after: "helper_method :authenticated?\n" do
54
- " helper_method :link_to_sign_in_or_out, :show_user_if_signed_in\n"
73
+ inject_into_file "app/controllers/concerns/authentication.rb", after: ":authenticated?" do
74
+ ", helper_method :link_to_sign_in_or_out, :show_user_if_signed_in"
55
75
  end
56
76
  end
57
77
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AuthenticationWithRegistrationGenerator
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: authentication_with_registration_generator
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
  - DAZ