avocado 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -14
  3. data/README.md +8 -43
  4. data/Rakefile +0 -2
  5. data/app/controllers/avocado/affirmations_controller.rb +21 -18
  6. data/app/controllers/avocado/base_controller.rb +26 -5
  7. data/app/controllers/avocado/credentials_controller.rb +41 -0
  8. data/app/controllers/avocado/emails_controller.rb +9 -17
  9. data/app/controllers/avocado/events_controller.rb +3 -3
  10. data/app/controllers/avocado/passwords_controller.rb +8 -8
  11. data/app/controllers/avocado/recoveries_controller.rb +8 -41
  12. data/app/controllers/avocado/registrations_controller.rb +7 -14
  13. data/app/controllers/avocado/sessions_controller.rb +21 -13
  14. data/app/controllers/avocado/verifications_controller.rb +14 -15
  15. data/app/views/avocado/affirmations/_form.html.erb +4 -0
  16. data/app/views/avocado/affirmations/edit.html.erb +7 -0
  17. data/app/views/avocado/affirmations/new.html.erb +2 -4
  18. data/app/views/avocado/{recoveries/edit.html.erb → credentials/_form.html.erb} +4 -13
  19. data/app/views/avocado/credentials/edit.html.erb +12 -0
  20. data/app/views/avocado/emails/_form.html.erb +8 -0
  21. data/app/views/avocado/emails/edit.html.erb +1 -6
  22. data/app/views/avocado/mailer/email_affirmation.text.erb +1 -1
  23. data/app/views/avocado/mailer/email_verification.text.erb +1 -1
  24. data/app/views/avocado/mailer/password_reset.text.erb +1 -1
  25. data/app/views/avocado/passwords/_form.html.erb +12 -0
  26. data/app/views/avocado/passwords/edit.html.erb +1 -9
  27. data/app/views/avocado/recoveries/_form.html.erb +4 -0
  28. data/app/views/avocado/recoveries/new.html.erb +2 -4
  29. data/app/views/avocado/registrations/_form.html.erb +12 -0
  30. data/app/views/avocado/registrations/new.html.erb +1 -12
  31. data/app/views/avocado/sessions/_form.html.erb +8 -0
  32. data/app/views/avocado/sessions/new.html.erb +1 -4
  33. data/app/views/avocado/verifications/edit.html.erb +7 -0
  34. data/config/locales/en.yml +45 -0
  35. data/config/routes/avocado.rb +11 -0
  36. data/config.ru +0 -2
  37. data/docs/USAGE.md +164 -0
  38. data/lib/avocado/authentication.rb +2 -4
  39. data/lib/avocado/current.rb +0 -2
  40. data/lib/avocado/engine.rb +5 -2
  41. data/lib/avocado/event.rb +0 -2
  42. data/lib/avocado/mailer.rb +0 -2
  43. data/lib/avocado/session.rb +6 -2
  44. data/lib/avocado/session_callbacks.rb +0 -2
  45. data/lib/avocado/user.rb +0 -2
  46. data/lib/avocado/user_callbacks.rb +0 -2
  47. data/lib/avocado/user_tokens.rb +0 -2
  48. data/lib/avocado/user_validations.rb +0 -2
  49. data/lib/avocado/version.rb +1 -3
  50. data/lib/avocado.rb +1 -2
  51. data/lib/generators/avocado/migrations/migrations_generator.rb +34 -0
  52. data/lib/generators/avocado/migrations/templates/create_events.rb.tt +12 -0
  53. data/lib/generators/avocado/migrations/templates/create_sessions.rb.tt +12 -0
  54. data/lib/generators/avocado/migrations/templates/create_users.rb.tt +11 -0
  55. data/lib/generators/avocado/views/views_generator.rb +21 -0
  56. metadata +27 -38
  57. data/config/routes.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a530ebf9605c2bb861d2da09da546513e68c4f647fc97c80686e07b32985cabe
4
- data.tar.gz: 3be481be5c31ce2ee3bb1ea1a2d796bb7f8cbe850f7ccf2de6f296384a656bb2
3
+ metadata.gz: e9ec8adfbc4563b5bbcddd5d5406963b4a9fe7d5a38765e35a86c9a3d35a09a0
4
+ data.tar.gz: 6db1dfa3a370661017533e44f2278a09daeece5c145267f05f0bced8943ea910
5
5
  SHA512:
6
- metadata.gz: cf3320eb985cc65c05c2da2d007697b4b9016d9a85f7ebebbd0735d744d7f8ca77096d86182c6761b63ea6f51f4b942a3c2dd363bb102ccc4ed53da6f5702c4f
7
- data.tar.gz: f0b021b9e0f3433f2034e5cccdc751a446b50bc870474376e1a39b84e973bbabfaef95b59d96f60986bbddc7695afe88b860bd2d1568f991a17b3b654d7f3995
6
+ metadata.gz: 9761662e0cf44fab571f6f6003aed2c0be2ae56424afbc1cc4b3ccb2f0d856a3e4d3b7a67c8a9e82b7d408977ebb30b4f1f61d9af0fd24db17c3fcb5c944cd89
7
+ data.tar.gz: a8021001d0f4864a36c981b2c5d18b71bca432f4f4b6fcde4ff6f07c38e7fc39f766dd39670041582cacb9a80526423eafd8156b5d8fc0580189679a1b67d144
data/CHANGELOG.md CHANGED
@@ -1,33 +1,78 @@
1
+ # Changelog
2
+
1
3
  ## [Unreleased]
2
4
 
5
+ ## [0.7.0] - 2023-08-10
6
+
7
+ ### Added
8
+
9
+ - An `avocado:views` generator copies engine views into application
10
+
11
+ ### Changed
12
+
13
+ - Flash messages for controllers moved to i18n yml
14
+ - View forms updated to use `_form` partials
15
+ - Move the reset phase of password recovery to a `Credentials` controller
16
+
17
+ ## [0.6.0] - 2023-07-25
18
+
19
+ ### Added
20
+
21
+ - Migration generator
22
+
23
+ ### Changed
24
+
25
+ - Affirmation and Verification paths require user action
26
+ - Use session `token` instead of `id` for signed cookie value
27
+
3
28
  ## [0.5.0] - 2023-07-21
4
29
 
5
- - Add controller for "passwordless" email-link sign-in
6
- - Add event class to log user auth events
7
- - Add user-facing email and password edit pages
8
- - Add various event logging callbacks
9
- - Sign out all non current sessions when password changes
30
+ ### Added
31
+
32
+ - Controller for "passwordless" email-link sign-in
33
+ - `Event` class to log user auth events
34
+ - User-facing email and password edit pages
35
+ - Misc event logging callbacks
36
+
37
+ ### Changed
38
+
39
+ - Sign out all non-current sessions when password changes
10
40
 
11
41
  ## [0.4.0] - 2023-07-19
12
42
 
43
+ ### Added
44
+
45
+ - Controllers for signing up, signing in, password reset and email verification
46
+
47
+ ### Changed
48
+
13
49
  - Convert the `Avocado::Mailer` module into a class
14
- - Add controllers for signing up, signing in, password reset and email
15
- verification
16
50
 
17
51
  ## [0.3.0] - 2023-07-17
18
52
 
19
- - Add an `Avocado::Mailer` which generates each of the signed ids
53
+ ### Added
54
+
55
+ - `Avocado::Mailer` which generates each of the signed ids
56
+
57
+ ### Changed
58
+
20
59
  - Rename `password_recovery` to `password_reset`
21
60
 
22
61
  ## [0.2.0] - 2023-07-15
23
62
 
24
- - Validate presence, uniqueness, and format on `email` attribute
25
- - Normalize email value during save
26
- - Validate password format and length
27
- - Include a token generator for password recovery
63
+ ### Added
64
+
65
+ - Validations for presence, uniqueness, and format on `email` attribute
66
+ - Normalizer for email value during save
67
+ - Validations on password format and length
68
+ - Token generator for password recovery
69
+
70
+ ### Changed
71
+
28
72
  - Rename `Avocado::UserConcern` to `Avocado::User`
29
73
 
30
74
  ## [0.1.0] - 2023-07-14
31
75
 
32
- - Initial release
33
- - Add `Avocado::UserConcern` which calls `has_secure_password`
76
+ ### Added
77
+
78
+ - `Avocado::UserConcern` which calls `has_secure_password`
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Avocado
1
+ # 🥑
2
2
 
3
- A collection of authentication tools for use in [Rails] 7.1+ applications.
3
+ Authentication library for [Rails] 7.1+ applications.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,49 +10,13 @@ Add to the application's Gemfile by executing:
10
10
 
11
11
  ## Usage
12
12
 
13
- If you are nervous about using Rails features directly, preferring to consume
14
- such features via a packaged gem, you can include some Avocado modules into your
15
- application to get authentication functionality.
16
-
17
- As a prerequisite, you should have a database schema with columns that match the
18
- users and sessions tables from [the demo app schema]. It's ok to have more
19
- columns, but you need at least what is shown there.
20
-
21
- With that set, include the modules into your classes:
22
-
23
- ```ruby
24
- class User < ApplicationRecord
25
- include Avocado::User
26
- end
27
-
28
- class Session < ApplicationRecord
29
- include Avocado::Session
30
- end
31
-
32
- class Event < ApplicationRecord
33
- include Avocado::Event
34
- end
35
-
36
- class ApplicationController < ActionController::Base
37
- include Avocado::Authentication
38
- end
39
- ```
40
-
41
- This will enable a few things:
42
-
43
- - Models will get validations, associations, and normalizations
44
- - Rails built-in `has_secure_password` is called within `User`
45
- - A mailer with signed token generators is created
46
- - Controllers and Routes for sign up, sign in, password reset, email
47
- verification, etc
48
-
49
- The `spec/internal` app within this repo has some example usage.
13
+ Read the [documentation] for more details or the [wiki] for background.
50
14
 
51
15
  ## Development
52
16
 
53
- After checking out the repo, run `bin/setup` to install dependencies. Then, run
54
- `rake spec` to run the tests. You can also run `bin/console` for an interactive
55
- prompt that will allow you to experiment.
17
+ After checking out the repo, run `bin/setup` to install dependencies. Use
18
+ `bin/rspec` to run the full spec suite and `bin/standardrb` to run the linter.
19
+ Running `bin/rake` will run specs & linter.
56
20
 
57
21
  ## Contributing
58
22
 
@@ -62,7 +26,8 @@ Bug reports and pull requests are welcome on [GitHub].
62
26
 
63
27
  The gem is available as open source under the terms of the [MIT License].
64
28
 
29
+ [documentation]: https://github.com/tcuwp/avocado/blob/main/docs/USAGE.md
65
30
  [GitHub]: https://github.com/tcuwp/avocado
66
31
  [MIT License]: https://opensource.org/licenses/MIT
67
32
  [Rails]: https://github.com/rails/rails
68
- [the demo app schema]: https://github.com/tcuwp/avocado/blob/main/spec/internal/db/schema.rb
33
+ [wiki]: https://github.com/tcuwp/avocado/wiki
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require "bundler/gem_tasks"
4
2
  require "rspec/core/rake_task"
5
3
 
@@ -1,23 +1,28 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Avocado
4
2
  class AffirmationsController < BaseController
5
3
  skip_before_action :authenticate
6
4
 
7
- before_action :set_user, only: :show
8
- before_action :verify_user, only: :create
5
+ before_action :set_user,
6
+ only: %i[edit update]
7
+ before_action :verify_user,
8
+ only: :create
9
9
 
10
10
  def new
11
11
  end
12
12
 
13
- def show
14
- sign_in(@user)
15
- redirect_to(root_path, notice: "Signed in successfully")
16
- end
17
-
18
13
  def create
19
14
  send_affirmation_email
20
- redirect_to new_session_path, notice: "Check your email for sign in instructions"
15
+ redirect_to new_session_path,
16
+ notice: t(".success")
17
+ end
18
+
19
+ def edit
20
+ end
21
+
22
+ def update
23
+ sign_in(@user)
24
+ redirect_to root_path,
25
+ notice: t(".success")
21
26
  end
22
27
 
23
28
  private
@@ -25,7 +30,8 @@ module Avocado
25
30
  def set_user
26
31
  @user = user_from_signed_affirmation_token
27
32
  rescue ActiveSupport::MessageVerifier::InvalidSignature
28
- redirect_to new_affirmation_path, alert: "That sign in link is invalid"
33
+ redirect_to new_affirmation_path,
34
+ alert: t(".errors.invalid_token")
29
35
  end
30
36
 
31
37
  def user_from_signed_affirmation_token
@@ -33,19 +39,16 @@ module Avocado
33
39
  end
34
40
 
35
41
  def verify_user
36
- unless user_from_params_email
37
- redirect_to new_affirmation_path, alert: "You can't sign in until you verify your email"
42
+ unless requested_verified_user
43
+ redirect_to new_affirmation_path,
44
+ alert: t(".errors.unverified_email")
38
45
  end
39
46
  end
40
47
 
41
48
  def send_affirmation_email
42
- mailer_for(user_from_params_email)
49
+ mailer_for(requested_verified_user)
43
50
  .email_affirmation
44
51
  .deliver_later
45
52
  end
46
-
47
- def user_from_params_email
48
- ::User.verified.find_by(email: params[:email])
49
- end
50
53
  end
51
54
  end
@@ -1,21 +1,42 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Avocado
4
2
  class BaseController < ApplicationController
3
+ FINDER_PARAMETERS = %i[email]
4
+
5
5
  private
6
6
 
7
7
  def verify_password_challenge
8
8
  unless current_user.authenticate(params_password_challenge)
9
- redirect_back alert: "Password challenge failed.", fallback_location: root_path
9
+ redirect_back fallback_location: root_path,
10
+ alert: t("avocado.filters.invalid_password_challenge")
10
11
  end
11
12
  end
12
13
 
13
14
  def params_password_challenge
14
- params.dig(:user, :password_challenge)
15
+ params
16
+ .dig(:user, :password_challenge)
17
+ end
18
+
19
+ def requested_verified_user
20
+ ::User
21
+ .verified
22
+ .find_by(email: finder_parameters[:email])
23
+ end
24
+
25
+ def finder_parameters
26
+ params
27
+ .require(:user)
28
+ .permit(FINDER_PARAMETERS)
15
29
  end
16
30
 
17
31
  def mailer_for(user)
18
- Avocado::Mailer.with(user: user)
32
+ Avocado::Mailer
33
+ .with(user: user)
34
+ end
35
+
36
+ def send_email_verification(user)
37
+ mailer_for(user)
38
+ .email_verification
39
+ .deliver_later
19
40
  end
20
41
  end
21
42
  end
@@ -0,0 +1,41 @@
1
+ module Avocado
2
+ class CredentialsController < BaseController
3
+ UPDATE_PARAMETERS = %i[password password_confirmation]
4
+
5
+ skip_before_action :authenticate
6
+
7
+ before_action :set_user
8
+
9
+ def edit
10
+ end
11
+
12
+ def update
13
+ if @user.update(update_parameters)
14
+ redirect_to new_session_path,
15
+ notice: t(".success")
16
+ else
17
+ render :edit, status: :unprocessable_entity
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def set_user
24
+ @user = user_from_signed_password_reset_token
25
+ rescue ActiveSupport::MessageVerifier::InvalidSignature
26
+ redirect_to new_recovery_path,
27
+ alert: t(".errors.invalid_token")
28
+ end
29
+
30
+ def user_from_signed_password_reset_token
31
+ ::User
32
+ .find_by_token_for!(:password_reset, params[:id])
33
+ end
34
+
35
+ def update_parameters
36
+ params
37
+ .require(:user)
38
+ .permit(UPDATE_PARAMETERS)
39
+ end
40
+ end
41
+ end
@@ -1,18 +1,19 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Avocado
4
2
  class EmailsController < BaseController
5
- PERMITTED_PARAMS = [:email]
3
+ UPDATE_PARAMETERS = %i[email]
6
4
 
7
5
  before_action :set_user
8
- before_action :verify_password_challenge, only: :update
6
+ before_action :verify_password_challenge,
7
+ only: :update
9
8
 
10
9
  def edit
11
10
  end
12
11
 
13
12
  def update
14
- if @user.update(user_params)
13
+ if @user.update(update_parameters)
15
14
  process_email_update
15
+ redirect_to root_path,
16
+ notice: t(".success")
16
17
  else
17
18
  render :edit, status: :unprocessable_entity
18
19
  end
@@ -24,25 +25,16 @@ module Avocado
24
25
  @user = current_user
25
26
  end
26
27
 
27
- def user_params
28
+ def update_parameters
28
29
  params
29
30
  .require(:user)
30
- .permit(PERMITTED_PARAMS)
31
+ .permit(UPDATE_PARAMETERS)
31
32
  end
32
33
 
33
34
  def process_email_update
34
35
  if @user.email_previously_changed?
35
- resend_email_verification
36
- redirect_to root_path, notice: "Your email has been changed"
37
- else
38
- redirect_to root_path
36
+ send_email_verification(@user)
39
37
  end
40
38
  end
41
-
42
- def resend_email_verification
43
- mailer_for(@user)
44
- .email_verification
45
- .deliver_later
46
- end
47
39
  end
48
40
  end
@@ -1,9 +1,9 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Avocado
4
2
  class EventsController < BaseController
5
3
  def index
6
- @events = current_user.events.newest_first
4
+ @events = current_user
5
+ .events
6
+ .newest_first
7
7
  end
8
8
  end
9
9
  end
@@ -1,18 +1,18 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Avocado
4
2
  class PasswordsController < BaseController
5
- PERMITTED_PARAMS = [:password, :password_confirmation, :password_challenge]
3
+ UPDATE_PARAMETERS = %i[password password_confirmation password_challenge]
6
4
 
7
5
  before_action :set_user
8
- before_action :verify_password_challenge, only: :update
6
+ before_action :verify_password_challenge,
7
+ only: :update
9
8
 
10
9
  def edit
11
10
  end
12
11
 
13
12
  def update
14
- if @user.update(user_params)
15
- redirect_to root_path, notice: "Your password has been changed"
13
+ if @user.update(update_parameters)
14
+ redirect_to root_path,
15
+ notice: t(".success")
16
16
  else
17
17
  render :edit, status: :unprocessable_entity
18
18
  end
@@ -24,10 +24,10 @@ module Avocado
24
24
  @user = current_user
25
25
  end
26
26
 
27
- def user_params
27
+ def update_parameters
28
28
  params
29
29
  .require(:user)
30
- .permit(PERMITTED_PARAMS)
30
+ .permit(UPDATE_PARAMETERS)
31
31
  .with_defaults(password_challenge: "")
32
32
  end
33
33
  end
@@ -1,63 +1,30 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Avocado
4
2
  class RecoveriesController < BaseController
5
- PERMITTED_PARAMS = %i[password password_confirmation]
6
-
7
3
  skip_before_action :authenticate
8
4
 
9
- before_action :set_user, only: %i[edit update]
10
- before_action :verify_user, only: :create
5
+ before_action :verify_user,
6
+ only: :create
11
7
 
12
8
  def new
13
9
  end
14
10
 
15
- def edit
16
- end
17
-
18
11
  def create
19
12
  send_password_reset_email
20
- redirect_to new_session_path, notice: "Check your email for reset instructions."
21
- end
22
-
23
- def update
24
- if @user.update(user_params)
25
- redirect_to new_session_path, notice: "Password reset successfully. Please sign in."
26
- else
27
- render :edit, status: :unprocessable_entity
28
- end
13
+ redirect_to new_session_path,
14
+ notice: t(".success")
29
15
  end
30
16
 
31
17
  private
32
18
 
33
- def set_user
34
- @user = user_from_signed_password_reset_token
35
- rescue ActiveSupport::MessageVerifier::InvalidSignature
36
- redirect_to new_recovery_path, alert: "Password reset link is invalid."
37
- end
38
-
39
- def user_from_signed_password_reset_token
40
- ::User.find_by_token_for!(:password_reset, params[:id])
41
- end
42
-
43
19
  def verify_user
44
- unless user_from_params_email
45
- redirect_to new_recovery_path, alert: "Verify email first before resetting password."
20
+ unless requested_verified_user
21
+ redirect_to new_recovery_path,
22
+ alert: t(".errors.unverified_email")
46
23
  end
47
24
  end
48
25
 
49
- def user_params
50
- params
51
- .require(:user)
52
- .permit(PERMITTED_PARAMS)
53
- end
54
-
55
- def user_from_params_email
56
- ::User.find_by(email: params[:email], verified: true)
57
- end
58
-
59
26
  def send_password_reset_email
60
- mailer_for(user_from_params_email)
27
+ mailer_for(requested_verified_user)
61
28
  .password_reset
62
29
  .deliver_later
63
30
  end
@@ -1,8 +1,6 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Avocado
4
2
  class RegistrationsController < BaseController
5
- PERMITTED_PARAMS = %i[email password password_confirmation]
3
+ INITIALIZATION_PARAMETERS = %i[email password password_confirmation]
6
4
 
7
5
  skip_before_action :authenticate
8
6
 
@@ -11,13 +9,14 @@ module Avocado
11
9
  end
12
10
 
13
11
  def create
14
- @user = ::User.new(user_params)
12
+ @user = ::User.new(initialization_parameters)
15
13
 
16
14
  if @user.save
17
15
  sign_in(@user)
18
16
 
19
- send_email_verification
20
- redirect_to root_path, notice: "Registration successful"
17
+ send_email_verification(@user)
18
+ redirect_to root_path,
19
+ notice: t(".success")
21
20
  else
22
21
  render :new, status: :unprocessable_entity
23
22
  end
@@ -25,16 +24,10 @@ module Avocado
25
24
 
26
25
  private
27
26
 
28
- def user_params
27
+ def initialization_parameters
29
28
  params
30
29
  .require(:user)
31
- .permit(PERMITTED_PARAMS)
32
- end
33
-
34
- def send_email_verification
35
- mailer_for(@user)
36
- .email_verification
37
- .deliver_later
30
+ .permit(INITIALIZATION_PARAMETERS)
38
31
  end
39
32
  end
40
33
  end
@@ -1,19 +1,21 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Avocado
4
2
  class SessionsController < BaseController
5
- PERMITTED_PARAMS = %i[email password]
3
+ AUTHENTICATION_PARAMETERS = %i[email password]
6
4
 
7
- skip_before_action :authenticate, only: %i[new create]
5
+ skip_before_action :authenticate,
6
+ only: %i[new create]
8
7
 
9
8
  with_options only: :create do
10
9
  before_action :verify_authentication_attempt
11
10
  end
12
11
 
13
- before_action :set_session, only: :destroy
12
+ before_action :set_session,
13
+ only: :destroy
14
14
 
15
15
  def index
16
- @sessions = current_user.sessions.newest_first
16
+ @sessions = current_user
17
+ .sessions
18
+ .newest_first
17
19
  end
18
20
 
19
21
  def new
@@ -23,35 +25,41 @@ module Avocado
23
25
  def create
24
26
  sign_in(authenticated_user)
25
27
 
26
- redirect_to root_path, notice: "Session created"
28
+ redirect_to root_path,
29
+ notice: t(".success")
27
30
  end
28
31
 
29
32
  def destroy
30
33
  @session.destroy
31
- redirect_to sessions_path, notice: "Session destroyed"
34
+ redirect_to sessions_path,
35
+ notice: t(".success")
32
36
  end
33
37
 
34
38
  private
35
39
 
36
- def session_params
40
+ def authentication_parameters
37
41
  params
38
42
  .require(:session)
39
- .permit(PERMITTED_PARAMS)
43
+ .permit(AUTHENTICATION_PARAMETERS)
40
44
  .with_defaults(email: "", password: "")
41
45
  end
42
46
 
43
47
  def authenticated_user
44
- @_authenticated_user ||= ::User.authenticate_by(session_params)
48
+ @_authenticated_user ||= ::User
49
+ .authenticate_by(authentication_parameters)
45
50
  end
46
51
 
47
52
  def verify_authentication_attempt
48
53
  if authenticated_user.blank?
49
- redirect_to new_session_path, alert: "Authentication failed"
54
+ redirect_to new_session_path,
55
+ alert: t(".errors.authentication")
50
56
  end
51
57
  end
52
58
 
53
59
  def set_session
54
- @session = current_user.sessions.find(params[:id])
60
+ @session = current_user
61
+ .sessions
62
+ .find(params[:id])
55
63
  end
56
64
  end
57
65
  end