Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #726] Thread safety: Session::Base.klass_name #729

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Added
* None
* Fixed
* None
* [#726](https://github.com/binarylogic/authlogic/issues/726) - Thread
safety in `Authlogic::Session::Base.klass_name`

## 6.2.0 (2020-09-03)

Expand Down
16 changes: 12 additions & 4 deletions lib/authlogic/session/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -776,15 +776,23 @@ def i18n_scope
# example, the UserSession class will authenticate with the User class
# unless you specify otherwise in your configuration. See
# authenticate_with for information on how to change this value.
#
# @api public
def klass
@klass ||= klass_name ? klass_name.constantize : nil
end

# The string of the model name class guessed from the actual session class name.
# The model name, guessed from the session class name, e.g. "User",
# from "UserSession".
#
# TODO: This method can return nil. We should explore this. It seems
# likely to cause a NoMethodError later, so perhaps we should raise an
# error instead.
#
# @api private
def klass_name
return @klass_name if defined?(@klass_name)
@klass_name = name.scan(/(.*)Session/)[0]
@klass_name = klass_name ? klass_name[0] : nil
return @klass_name if instance_variable_defined?(:@klass_name)
@klass_name = name.scan(/(.*)Session/)[0]&.first
end

# The name of the method you want Authlogic to create for storing the
Expand Down