authentication_with_registration_generator 0.3.6 → 0.3.7

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: '09af8b2c0d27ae4fd78d65f2af3c50e30beccf1449828f8fceebbcd4d1908072'
4
- data.tar.gz: c835170056b1f728c1262334d6962dd8302a5e18e812f8f0d8c68aef37a1b6fc
3
+ metadata.gz: c4789ca10d281551213ea556cd5c4c4e20ad34f6a2326491a3ac1878ddf47237
4
+ data.tar.gz: 2bd3283c0dfe7f0f8e2ade71d331ad4efab0e6715eb9f5f33f1d7bf8e5ebc62b
5
5
  SHA512:
6
- metadata.gz: 2b67e1808f4d4ad1a3d3e77c9774c508566ce665826a9691c0a00510cc30c35ce34e4c8ebe49036d258c0e6f31f02a54eeed077647604a1fadb09cfe03861de1
7
- data.tar.gz: e82b32cde7d17818971065f6cd224b2f196890d9143d5ea776fa2fc2bec48e801c6f7133f1beaf225805ae17f1f2cbbb32117e2fb717b20695274b2bf77b4ba6
6
+ metadata.gz: a5ef356ae177579a35b82a6bc84b68e7d5488f73d73f6015541d521998334057d61165ff2588e90208020e7486e4a57b5a93c45d9db8e5a54e84281f15e02762
7
+ data.tar.gz: 3270af7ffc23f2c5d4361dae4baf8d211d2188eb1732014a54fb0bab921f56b0236c070a8caad881a34c909ce77d527a7bb4cc3e89befdf527fc96139dba30f3
data/README.md CHANGED
@@ -6,24 +6,26 @@ A Rails Generator that adds registration pages to the Authentication Generator a
6
6
  * Adds a registration page which will create a new user with an email address and password.
7
7
  * Adds a link to the registration page on the sign_in page
8
8
  * Adds `new_registration_path` and `registration_path` routes
9
- * Adds '/sign_in' and '/sign_out' routes as alias to '/session/new' and 'session', these can be accessed using the `sign_in_path` and `sign_out_path, method: :delete` helpers
9
+ * Adds '/sign_in' and '/sign_out' routes as alias to '/session/new' and 'session', these can be accessed using the `sign_in_path` and `sign_out_path` helpers
10
10
  * Adds a `link_to_sign_in_or_out` helper that will display a sign out or sign in link depending on if a user is authenticated or not
11
11
  * Adds a `show_user_if_signed_in` method that displays a "signed in as username" message if the user is signed in
12
12
 
13
+ Much of this was based on [this excellent tutorial](https://www.rubanonrails.com/courses/rails-cookie-authentication/lessons/introduction) by @alexandreruban (https://github.com/alexandreruban) that will help you understand how the Authentication Generator works.
14
+
13
15
  ## Installation
14
16
 
15
17
  Install the gem and add to the application's Gemfile by executing:
16
18
 
17
- $ bundle add registration_generator
19
+ $ bundle add authentication_with_registration_generator
18
20
 
19
21
  If bundler is not being used to manage dependencies, install the gem by executing:
20
22
 
21
- $ gem install registration_generator
23
+ $ gem install authentication_with_registration_generator
22
24
 
23
25
  ## Usage
24
26
 
25
27
  ```bash
26
- rails generate registration
28
+ rails generate authentication
27
29
  ```
28
30
 
29
31
  ## Development
@@ -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
@@ -1,13 +1,13 @@
1
1
  class RegistrationsController < ApplicationController
2
2
  allow_unauthenticated_access
3
-
3
+
4
4
  def new
5
5
  @user = User.new
6
6
  end
7
-
7
+
8
8
  def create
9
9
  @user = User.new(user_params)
10
-
10
+
11
11
  if @user.save
12
12
  start_new_session_for @user
13
13
  redirect_to after_authentication_url, notice: "You have successfully registered!"
@@ -15,10 +15,10 @@ class RegistrationsController < ApplicationController
15
15
  render :new, status: :unprocessable_entity
16
16
  end
17
17
  end
18
-
18
+
19
19
  private
20
-
20
+
21
21
  def user_params
22
- params.require(:user).permit(:email_address, :password)
22
+ params.expect(user: [ :email_address, :password ])
23
23
  end
24
24
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AuthenticationGenerator
4
- VERSION = "0.3.6"
4
+ VERSION = "0.3.7"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authentication_with_registration_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - DAZ
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-24 00:00:00.000000000 Z
10
+ date: 2025-03-09 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -36,10 +36,9 @@ files:
36
36
  - lib/generators/authentication/authentication_generator.rb
37
37
  - lib/generators/authentication/templates/registration_form.html.erb
38
38
  - lib/generators/authentication/templates/registrations_controller.rb
39
- - lib/generators/authentication/templates/sign_in_form.html.erb
40
39
  - lib/generators/authentication_generator.rb
41
40
  - lib/generators/version.rb
42
- homepage: https://github.com/your_username/registration_generator
41
+ homepage: https://github.com/daz4126/authentication_with_registration_generator
43
42
  licenses:
44
43
  - MIT
45
44
  metadata: {}
@@ -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>