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: 94904540bd185fcff1ca6e6ce29bca6cbb12a24a19f8e40af9e6a88bf5c1d393
4
- data.tar.gz: e2b854ed675921de2338e1b3d88170d7ba19a626c93f15821ec105e9c79fa8b9
3
+ metadata.gz: 6c65dfd155961b5b1faccb26c79a4a9725e538e3c39f2013a6e3d1a5d0d2f1eb
4
+ data.tar.gz: df9120408b1d4da61c55f70cc3d26c4aee88e18617ba3059bf469ce846c5a14a
5
5
  SHA512:
6
- metadata.gz: 97c5e15965347378ab9c66dabaa836b631d1a28fc0de99130dc5884a45df7ba47f46baddc2039d0ee7ce04042364b0cef681cc30eca1eae10b2a21afccdaa176
7
- data.tar.gz: c40a5b269e783a0c5f917d75fbc64e72f363a1593423bb62701719e44442365c332dee94917c5d1733f43beac57ac0f5e51b48a0191280a266d3b0657ab356da
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 'registration_form.html.erb', "app/views/registrations/new.html.erb"
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 'sign_in_form.html.erb', "app/views/sessions/new.html.erb", force: true
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 'registrations_controller.rb', "app/controllers/registrations_controller.rb"
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 'sign_in', to: 'session#new', as :sign_in"
23
- route "delete 'sign_out', to: 'session#destroy', as :sign_out"
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", <<-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
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
- 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
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
- 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
-
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 root_path, notice: "You have successfully registered!"
13
+ redirect_to after_authentication_url, notice: "You have successfully registered!"
15
14
  else
16
15
  render :new, status: :unprocessable_entity
17
16
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RegistrationGenerator
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: registration_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DAZ