authentication_with_registration_generator 0.3.6 → 0.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0b23f75ebcd6eb2f59c6de139f976c9fef290c3c815d0dff6ae7a94d1ee6551
|
4
|
+
data.tar.gz: 37fd9f913c6a36515c64a4490fdd43869d13de837db2b6f840b9c26bb3af5189
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1ff85084c2c42ab83cd6d5858d55cacb5d83bf7617b415b9d067c97109f5ef45102dd01eec8e6e420571c68d8cdaca34f29763a85506e8a934ad0ef630251cf
|
7
|
+
data.tar.gz: 2084a38f791e245e7e6eb6a30dff29344a770b8597ee3863246d4a6c285ffcbbabe048688b61c1a086753794b7352ef42ac4fa91091ad53cec3b1b7f5d2473b9
|
@@ -11,6 +11,15 @@ module Authentication
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def add_uniqueness_validation
|
15
|
+
user_model_path = "app/models/user.rb"
|
16
|
+
|
17
|
+
# Check if the validation already exists to prevent duplication
|
18
|
+
if File.readlines(user_model_path).grep(/validates_uniqueness_of :email_address/).empty?
|
19
|
+
inject_into_class user_model_path, User, " validates :email_address, uniqueness: true\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
14
23
|
def create_view
|
15
24
|
template "registration_form.html.erb", "app/views/registrations/new.html.erb"
|
16
25
|
end
|
@@ -33,7 +42,7 @@ module Authentication
|
|
33
42
|
if File.exist?(session_view_path)
|
34
43
|
# Replace the "Forgot password?" link with the new links
|
35
44
|
gsub_file session_view_path, /<br>\s*<%= link_to "Forgot password\?", new_password_path %>/ do |match|
|
36
|
-
"<p>\n
|
45
|
+
"<p>\n <%%= link_to 'Forgot password?', new_password_path %> | \n <%= link_to 'No Account? Register here', new_registration_path %>\n</p>"
|
37
46
|
end
|
38
47
|
else
|
39
48
|
# If the file doesn't exist, handle it accordingly (e.g., raise an error or create the file)
|
@@ -48,13 +57,13 @@ module Authentication
|
|
48
57
|
def link_to_sign_in_or_out
|
49
58
|
if authenticated?
|
50
59
|
# Return the form as a string
|
51
|
-
"<form class
|
52
|
-
<input type
|
53
|
-
<button type
|
54
|
-
<input type
|
60
|
+
"<form class=\"button_to\" action=\"\#{sign_out_path}\" accept-charset=\"UTF-8\" method=\"post\">
|
61
|
+
<input type=\"hidden\" name=\"_method\" value=\"delete\" autocomplete=\"off\" />
|
62
|
+
<button type=\"submit\">Sign Out</button>
|
63
|
+
<input type=\"hidden\" name=\"authenticity_token\" value=\"\#{form_authenticity_token}\" autocomplete=\"off\" />
|
55
64
|
</form>".html_safe
|
56
65
|
else
|
57
|
-
"<a href
|
66
|
+
"<a href=\"\#{sign_in_path}\">Sign In</a>".html_safe
|
58
67
|
end
|
59
68
|
end
|
60
69
|
|
@@ -1,24 +1,24 @@
|
|
1
1
|
class RegistrationsController < ApplicationController
|
2
2
|
allow_unauthenticated_access
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
3
|
+
|
4
|
+
def new
|
5
|
+
@user = User.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def create
|
9
|
+
@user = User.new(user_params)
|
10
|
+
|
11
|
+
if @user.save
|
12
|
+
start_new_session_for @user
|
13
|
+
redirect_to after_authentication_url, notice: "You have successfully registered!"
|
14
|
+
else
|
15
|
+
render :new, status: :unprocessable_entity
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def user_params
|
22
|
+
params.require(:user).permit(:email_address, :password)
|
23
|
+
end
|
24
24
|
end
|
data/lib/generators/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authentication_with_registration_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DAZ
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-28 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: rails
|
@@ -36,13 +37,13 @@ files:
|
|
36
37
|
- lib/generators/authentication/authentication_generator.rb
|
37
38
|
- lib/generators/authentication/templates/registration_form.html.erb
|
38
39
|
- lib/generators/authentication/templates/registrations_controller.rb
|
39
|
-
- lib/generators/authentication/templates/sign_in_form.html.erb
|
40
40
|
- lib/generators/authentication_generator.rb
|
41
41
|
- lib/generators/version.rb
|
42
42
|
homepage: https://github.com/your_username/registration_generator
|
43
43
|
licenses:
|
44
44
|
- MIT
|
45
45
|
metadata: {}
|
46
|
+
post_install_message:
|
46
47
|
rdoc_options: []
|
47
48
|
require_paths:
|
48
49
|
- lib
|
@@ -57,7 +58,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
58
|
- !ruby/object:Gem::Version
|
58
59
|
version: '0'
|
59
60
|
requirements: []
|
60
|
-
rubygems_version: 3.
|
61
|
+
rubygems_version: 3.5.11
|
62
|
+
signing_key:
|
61
63
|
specification_version: 4
|
62
64
|
summary: A Rails generator for user authenticatin with extra registration pages, routes
|
63
65
|
and helpers
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<%%= tag.div(flash[:alert], style: "color:red") if flash[:alert] %>
|
2
|
-
<%%= tag.div(flash[:notice], style: "color:green") if flash[:notice] %>
|
3
|
-
|
4
|
-
<%%= form_with url: session_path do |form| %>
|
5
|
-
<%%= form.email_field :email_address, required: true, autofocus: true, autocomplete: "username", placeholder: "Enter your email address", value: params[:email_address] %><br>
|
6
|
-
<%%= form.password_field :password, required: true, autocomplete: "current-password", placeholder: "Enter your password", maxlength: 72 %><br>
|
7
|
-
<%%= form.submit "Sign in" %>
|
8
|
-
<%% end %>
|
9
|
-
<p>
|
10
|
-
<%%= link_to "Forgot password?", new_password_path %> |
|
11
|
-
<%%= link_to "No Account? Register here", new_registration_path %>
|
12
|
-
</p>
|