I tried to integrate the gem simple_discussion on a Rails application. I do not using Devise for authentication but Sorcery and Cancancan.
As I think the method 'user_signed_in?' is a Devise method, is it possible to adapt it with Sorcery writing this method from Scratch ??
I know that the method 'logged_in?' is available in views in the Sorcery documentation, can I try to make the method 'user_signed_in?' equal to the method 'logged_in?' ??
These are the methods for Devise and for Sorcery:
Devise
#signed_in?(scope = nil) ⇒ Boolean
Return true if the given scope is signed in session. If no scope given, return true if any scope is signed in. This will run authentication hooks, which may cause exceptions to be thrown from this method; if you simply want to check if a scope has already previously been authenticated without running authentication hooks, you can directly call warden.authenticated?(scope: scope)
Returns: (Boolean)
`# File 'lib/devise/controllers/sign_in_out.rb', line 13
def signed_in?(scope=nil)
[scope || Devise.mappings.keys].flatten.any? do |_scope|
warden.authenticate?(scope: _scope)
end
end`
Sorcery
#logged_in? ⇒ Boolean
shows if user is logged in, but it not show if user is online - see online?
Returns: (Boolean)
`# File 'lib/sorcery/model/submodules/activity_logging.rb', line 60
def logged_in?
return false if self.send(sorcery_config.last_login_at_attribute_name).nil?
return true if self.send(sorcery_config.last_login_at_attribute_name).present? and self.send(sorcery_config.last_logout_at_attribute_name).nil?
self.send(sorcery_config.last_login_at_attribute_name) > self.send(sorcery_config.last_logout_at_attribute_name)
end`
I doubt a lot about what's the way to do it..