Skip to content

Commit

Permalink
Merge pull request #78 from lazaronixon/delegate-user-to-session
Browse files Browse the repository at this point in the history
Delegate user to session instead of a new a user attribute
  • Loading branch information
lazaronixon authored Jul 17, 2023
2 parents 3bf783b + b911879 commit 6c8162f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/generators/authentication/templates/models/current.rb.tt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
class Current < ActiveSupport::CurrentAttributes
attribute :session, :user
attribute :session
attribute :user_agent, :ip_address
<%- if options.tenantable? %>
attribute :account
<%- end -%>

def session=(session)
super; self.user = session.user
end
delegate :user, to: :session, allow_nil: true
<%- if options.tenantable? %>
def user=(user)
super; self.account = user.account
def session=(session)
super; self.account = session.user.account
end
<%- end -%>
end

0 comments on commit 6c8162f

Please sign in to comment.