registration_generator 0.3.0 → 0.3.2
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/lib/generators/registration/registration_generator.rb +35 -32
- data/lib/generators/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d96e1e09cacff899a32ee52965cbf62381b485e920e0e8398c492c0ab15c9c6
|
4
|
+
data.tar.gz: a93474810b00cbfcb74def32c5a434ca494b415948216cd5ce84f7f7849cff97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 062c4297c6e1cc1c80d896a5eb4ca503cbd5fd77e589ca6375e933859f67da6ec63235dd6cefc437c93cd4481feab95e2716c59023fe52668254bf252b9bc623
|
7
|
+
data.tar.gz: 3047555cedffc8fadd55b1fd4f52a9be77e0f730efceab7a5933dc77b57c92e58b1966cf35d13625e0f89b5e34385054842e73a35aeb72738ddb1663ff3a8209
|
@@ -19,43 +19,46 @@ module Registration
|
|
19
19
|
|
20
20
|
def add_routes
|
21
21
|
route "resource :registration, only: [:new, :create]"
|
22
|
-
route "get 'sign_in', to: '
|
23
|
-
route "delete 'sign_out', to: '
|
22
|
+
route "get 'sign_in', to: 'sessions#new', as: :sign_in"
|
23
|
+
route "delete 'sign_out', to: 'sessions#destroy', as: :sign_out"
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
def create_helper
|
27
|
+
create_file "app/helpers/authentication_helper.rb", <<~RUBY
|
28
|
+
module AuthenticationHelper
|
29
|
+
def link_to_sign_in_or_out(show_user: false)
|
30
|
+
if authenticated?
|
31
|
+
button_to "Sign Out", sign_out_path, method: :delete
|
32
|
+
else
|
33
|
+
link_to "Sign In", sign_in_path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def show_username_if_signed_in(text = "Signed in as")
|
38
|
+
if authenticated?
|
39
|
+
content = "\#{text} \#{Current.user.name}"
|
40
|
+
content.html_safe
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
RUBY
|
45
|
+
|
46
|
+
# Inject include statement at the correct place
|
47
|
+
inject_into_class "app/controllers/application_controller.rb", "ApplicationController", <<~RUBY
|
48
|
+
include AuthenticationHelper
|
49
|
+
RUBY
|
35
50
|
end
|
51
|
+
|
52
|
+
|
36
53
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
54
|
+
def add_name_method_to_user
|
55
|
+
inject_into_class "app/models/user.rb", User, <<-RUBY
|
56
|
+
|
57
|
+
def name
|
58
|
+
email_address
|
41
59
|
end
|
60
|
+
|
61
|
+
RUBY
|
42
62
|
end
|
43
63
|
end
|
44
|
-
RUBY
|
45
|
-
|
46
|
-
inject_into_class "app/controllers/application_controller.rb", ApplicationController, <<-RUBY
|
47
|
-
|
48
|
-
include AuthenticationHelper
|
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
|
-
|
59
|
-
RUBY
|
60
|
-
end
|
61
64
|
end
|
data/lib/generators/version.rb
CHANGED