registration_generator 0.3.1 → 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: 6c65dfd155961b5b1faccb26c79a4a9725e538e3c39f2013a6e3d1a5d0d2f1eb
|
4
|
+
data.tar.gz: df9120408b1d4da61c55f70cc3d26c4aee88e18617ba3059bf469ce846c5a14a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccefbd2d14c66cf3914d9c5ea7b5bbdba587681269d9726243990be29bc470e22e6a932e34c8d34eb83ce82c81becda5af4e5a2c2a181c97cdde7f61bc9742c1
|
7
|
+
data.tar.gz: 99f711ea931463a64b6d0863011e804f59f976f58762b5a1efef9192311d3235fc306d48c8b9a68d0f9263734e6e788e5260d2936512f3c013291766ec0ca7ea
|
@@ -6,57 +6,48 @@ module Registration
|
|
6
6
|
source_root File.expand_path("templates", __dir__)
|
7
7
|
|
8
8
|
def create_view
|
9
|
-
template
|
9
|
+
template "registration_form.html.erb", "app/views/registrations/new.html.erb"
|
10
10
|
end
|
11
11
|
|
12
12
|
def create_sign_in
|
13
|
-
template
|
13
|
+
template "sign_in_form.html.erb", "app/views/sessions/new.html.erb", force: true
|
14
14
|
end
|
15
15
|
|
16
16
|
def create_controller
|
17
|
-
template
|
17
|
+
template "registrations_controller.rb", "app/controllers/registrations_controller.rb"
|
18
18
|
end
|
19
19
|
|
20
20
|
def add_routes
|
21
|
+
route "root \"/\""
|
21
22
|
route "resource :registration, only: [:new, :create]"
|
22
|
-
route "get
|
23
|
-
route "delete
|
23
|
+
route "get \"sign_in\", to: \"sessions#new\", as: :sign_in"
|
24
|
+
route "delete \"sign_out\", to: \"sessions#destroy\", as: :sign_out"
|
24
25
|
end
|
25
26
|
|
26
27
|
def create_helper
|
27
|
-
create_file "app/helpers/authentication_helper.rb",
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
create_file "app/helpers/authentication_helper.rb", <<~RUBY
|
29
|
+
module AuthenticationHelper
|
30
|
+
def link_to_sign_in_or_out(show_user: false)
|
31
|
+
if authenticated?
|
32
|
+
button_to "Sign Out", sign_out_path, method: :delete
|
33
|
+
else
|
34
|
+
link_to "Sign In", sign_in_path
|
35
|
+
end
|
34
36
|
end
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
|
38
|
+
def show_username_if_signed_in
|
39
|
+
if authenticated?
|
40
|
+
content = "Signed in as \#{Current.user.email_address}"
|
41
|
+
content.html_safe
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
|
-
end
|
44
45
|
RUBY
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
RUBY
|
50
|
-
end
|
51
|
-
|
52
|
-
def add_name_method_to_user
|
53
|
-
inject_into_class "app/models/user.rb", User, <<-RUBY
|
54
|
-
|
55
|
-
def name
|
56
|
-
email_address
|
57
|
-
end
|
58
|
-
|
47
|
+
# Inject include statement at the correct place
|
48
|
+
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", <<~RUBY
|
49
|
+
include AuthenticationHelper
|
59
50
|
RUBY
|
60
51
|
end
|
61
52
|
end
|
62
|
-
end
|
53
|
+
end
|
@@ -2,16 +2,15 @@ class RegistrationsController < ApplicationController
|
|
2
2
|
allow_unauthenticated_access
|
3
3
|
|
4
4
|
def new
|
5
|
-
redirect_to root_path if authenticated?
|
6
5
|
@user = User.new
|
7
6
|
end
|
8
7
|
|
9
8
|
def create
|
10
9
|
@user = User.new(user_params)
|
11
|
-
|
10
|
+
|
12
11
|
if @user.save
|
13
12
|
start_new_session_for @user
|
14
|
-
redirect_to
|
13
|
+
redirect_to after_authentication_url, notice: "You have successfully registered!"
|
15
14
|
else
|
16
15
|
render :new, status: :unprocessable_entity
|
17
16
|
end
|
data/lib/generators/version.rb
CHANGED