registration_generator 0.5.0 → 0.6.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 +4 -4
- data/README.md +3 -9
- data/lib/generators/registration/USAGE +2 -0
- data/lib/generators/registration/registration_generator.rb +11 -11
- data/lib/generators/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b599e43281ddae39934d872b1cf29409c6f091b0f6bde51a7c243e40a385432a
|
4
|
+
data.tar.gz: 5da9f59ddac3acc1fb50e87c2192f3e40a597641ff8167c705a0f6137b413dc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c3a7f83e2859ea5abc8d5801a05babe5ab25085d6340f863db85b0990159d759a1b0331d0ab786436e86de17de527b2f9d12ea71940f3519efddf1b4d55c794
|
7
|
+
data.tar.gz: ce5f5afeff0d2b99cca4cb12e292d702dcd0f2732429fb2ba15366311145f5152e2cfef2da8aab9c76bfc66040a2997d4f0cd49dc837b95103907ce72e99c7f1
|
data/README.md
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
A Rails Generator that adds registration pages to the Authentication Generator as well as some useful routes and helper methods.
|
4
4
|
|
5
|
+
* Runs the Authentication generator
|
5
6
|
* Adds a registration page which will create a new user with an email address and password.
|
7
|
+
* Adds a link to the registration page on the sign_in page
|
6
8
|
* Adds `new_registration_path` and `registration_path` routes
|
7
|
-
* Adds a registration link on the sign_in page
|
8
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
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
|
10
|
-
* Adds a `
|
11
|
-
* Adds a `name` method to the user model that is an alias for the email_address, but can be changed
|
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
13
|
## Installation
|
14
14
|
|
@@ -22,12 +22,6 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
```bash
|
26
|
-
rails generate authentication
|
27
|
-
```
|
28
|
-
|
29
|
-
Then run the registration generator:
|
30
|
-
|
31
25
|
```bash
|
32
26
|
rails generate registration
|
33
27
|
```
|
@@ -5,6 +5,10 @@ module Registration
|
|
5
5
|
class RegistrationGenerator < Rails::Generators::Base
|
6
6
|
source_root File.expand_path("templates", __dir__)
|
7
7
|
|
8
|
+
def run_auth_generator
|
9
|
+
invoke "rails:authentication"
|
10
|
+
end
|
11
|
+
|
8
12
|
def create_view
|
9
13
|
template "registration_form.html.erb", "app/views/registrations/new.html.erb"
|
10
14
|
end
|
@@ -23,9 +27,10 @@ module Registration
|
|
23
27
|
route "delete \"sign_out\", to: \"sessions#destroy\", as: :sign_out"
|
24
28
|
end
|
25
29
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
30
|
+
def update_authentication_concern
|
31
|
+
inject_into_file "app/controllers/concerns/authentication.rb", before: "private\n" do
|
32
|
+
<<~RUBY
|
33
|
+
|
29
34
|
def link_to_sign_in_or_out
|
30
35
|
if authenticated?
|
31
36
|
button_to "Sign Out", sign_out_path, method: :delete
|
@@ -34,18 +39,13 @@ module Registration
|
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
37
|
-
def
|
42
|
+
def show_user_if_signed_in
|
38
43
|
if authenticated?
|
39
44
|
"Signed in as \#{Current.user.email_address}"
|
40
45
|
end
|
41
46
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
# Inject include statement at the correct place
|
46
|
-
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", <<~RUBY
|
47
|
-
include AuthenticationHelper
|
48
|
-
RUBY
|
47
|
+
RUBY
|
48
|
+
end
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/generators/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: registration_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DAZ
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|