registration_generator 0.1.0 → 0.2.1
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: 5fe551f01abee2b587f0543eca72ae4a7d278b42e36867d08bae6ee536a2801a
|
4
|
+
data.tar.gz: e981f3073cd587feb844a3de9eea6707ca2093883c72981a5847e27846744f1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bcd4197cb09a1628abedecb268ec5e4e25dd1fa4d9c33926ce7603624c5b14dd83c0b67c7d8240c039d9149e6a9c79fce3f75ba2b4e83d5a899b0352ff45bf1
|
7
|
+
data.tar.gz: d70430157709e845357c9649df4597f0d10ccdb0366c07501bddbc6cd56e3bddf2ee3411cc4b91132c973c25f822a5c03cd609978e11a1f93559763d5dec3e89
|
data/README.md
CHANGED
@@ -1,24 +1,36 @@
|
|
1
1
|
# RegistrationGenerator
|
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
|
-
|
5
|
+
* Adds a registration page which will create a new user with an email address and password.
|
6
|
+
* Adds `new_registration_path` and `registration_path` routes
|
7
|
+
* Adds a registration link on the sign_in page
|
8
|
+
* 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 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 `show_username_if_signed_in` method that displays a "signed in as username" message if the user is signed in
|
11
|
+
* Adds a `name` method to the user model that is an alias for the email_address, but can be changed
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
9
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
-
|
11
15
|
Install the gem and add to the application's Gemfile by executing:
|
12
16
|
|
13
|
-
$ bundle add
|
17
|
+
$ bundle add registration_generator
|
14
18
|
|
15
19
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
20
|
|
17
|
-
$ gem install
|
21
|
+
$ gem install registration_generator
|
18
22
|
|
19
23
|
## Usage
|
20
24
|
|
21
|
-
|
25
|
+
```bash
|
26
|
+
rails generate authentication
|
27
|
+
```
|
28
|
+
|
29
|
+
Then run the registration generator:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
rails generate registration
|
33
|
+
```
|
22
34
|
|
23
35
|
## Development
|
24
36
|
|
@@ -28,7 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
40
|
|
29
41
|
## Contributing
|
30
42
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/daz4126/registration_generator.
|
32
44
|
|
33
45
|
## License
|
34
46
|
|
@@ -20,6 +20,44 @@ module RegistrationGenerator
|
|
20
20
|
|
21
21
|
def add_routes
|
22
22
|
route "resource :registration, only: [:new, :create]"
|
23
|
+
route "get 'sign_in', to: 'session#new', as :sign_in"
|
24
|
+
route "delete 'sign_out', to: 'session#destroy', as :sign_out"
|
23
25
|
end
|
24
26
|
end
|
27
|
+
|
28
|
+
def create_helper
|
29
|
+
create_file "app/helpers/authentication_helper.rb", <<-RUBY
|
30
|
+
module AuthenticationHelper
|
31
|
+
def link_to_sign_in_or_out(show_user: false)
|
32
|
+
if authenticated?
|
33
|
+
button_to "Sign Out", sign_out_path, method: :delete
|
34
|
+
else
|
35
|
+
link_to "Sign In", sign_in_path
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def show_username_if_signed_in(text="Signed in as")
|
40
|
+
if authenticated?
|
41
|
+
content = "#{text} #{Current.user.name}"
|
42
|
+
content.html_safe
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
RUBY
|
47
|
+
|
48
|
+
inject_into_class "app/controllers/application_controller.rb", ApplicationController, <<-RUBY
|
49
|
+
|
50
|
+
include AuthenticationHelper
|
51
|
+
RUBY
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_name_method_to_user
|
55
|
+
inject_into_class "app/models/user.rb", User, <<-RUBY
|
56
|
+
|
57
|
+
def name
|
58
|
+
email_address
|
59
|
+
end
|
60
|
+
|
61
|
+
RUBY
|
62
|
+
end
|
25
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: registration_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- DAZ
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-22 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
@@ -27,7 +26,7 @@ dependencies:
|
|
27
26
|
description: This gem provides a Rails generator to create a registration form and
|
28
27
|
related files.
|
29
28
|
email:
|
30
|
-
-
|
29
|
+
- darren.jones@hey.com
|
31
30
|
executables: []
|
32
31
|
extensions: []
|
33
32
|
extra_rdoc_files: []
|
@@ -40,28 +39,26 @@ files:
|
|
40
39
|
- lib/registration_generator/templates/registration_form.html.erb
|
41
40
|
- lib/registration_generator/templates/registrations_controller.rb
|
42
41
|
- lib/registration_generator/templates/sign_in_form.html.erb
|
43
|
-
- lib/
|
42
|
+
- lib/version.rb
|
44
43
|
homepage: https://github.com/your_username/registration_generator
|
45
44
|
licenses:
|
46
45
|
- MIT
|
47
46
|
metadata: {}
|
48
|
-
post_install_message:
|
49
47
|
rdoc_options: []
|
50
48
|
require_paths:
|
51
49
|
- lib
|
52
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
51
|
requirements:
|
54
|
-
- - "
|
52
|
+
- - "~>"
|
55
53
|
- !ruby/object:Gem::Version
|
56
|
-
version: '0'
|
54
|
+
version: '3.0'
|
57
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
56
|
requirements:
|
59
57
|
- - ">="
|
60
58
|
- !ruby/object:Gem::Version
|
61
59
|
version: '0'
|
62
60
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
64
|
-
signing_key:
|
61
|
+
rubygems_version: 3.6.3
|
65
62
|
specification_version: 4
|
66
63
|
summary: A Rails generator for user registration
|
67
64
|
test_files: []
|