-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from marcel-strzalka/bugfix/devise
Bugfix/devise
- Loading branch information
Showing
3 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
# This controller is a workaround for a currently (05.10.22) existing bug related to | ||
# Turbo and Devise. Without it flash messages in login and registration forms are | ||
# not displayed at all which is quite confusing to potential users. | ||
# | ||
# Fixed thanks to: https://github.com/hotwired/turbo/issues/45#issuecomment-753370898 | ||
# | ||
# TODO: Remove this workaround when the following issue is resolved: | ||
# https://github.com/heartcombo/devise/issues/5446 | ||
|
||
class TurboController < ApplicationController | ||
class Responder < ActionController::Responder | ||
def to_turbo_stream | ||
controller.render(options.merge(formats: :html)) | ||
rescue ActionView::MissingTemplate => e | ||
raise e if get? | ||
|
||
if has_errors? && default_action | ||
render rendering_options.merge(formats: :html, status: :unprocessable_entity) | ||
else | ||
redirect_to navigation_location | ||
end | ||
end | ||
end | ||
|
||
self.responder = Responder | ||
respond_to :html, :turbo_stream | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class User < ApplicationRecord | ||
BCRYPT_BYTESIZE_LIMIT = 72 | ||
|
||
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable | ||
|
||
has_many :reservations, dependent: :destroy | ||
|
||
enum :role, %i[customer manager] | ||
|
||
validate do | ||
errors.add(:base, 'Password is too long') if password.bytesize > BCRYPT_BYTESIZE_LIMIT | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters