From d9deeba582b64b75e249f6ecd86768e5a49e22a6 Mon Sep 17 00:00:00 2001 From: Alex Matchneer Date: Tue, 23 Jan 2018 10:18:37 -0500 Subject: [PATCH] Fix `signed_in?` docs w.r.t. running auth hooks (#4733) Addresses #4599 The docs previously mentioned that authentication hooks are not run when `signed_in?` is called, when in fact they are. This commit fixes the comment and suggests calling `authenticated?` on warden directly as an alternative for when you _don't_ want to run auth hooks. --- lib/devise/controllers/sign_in_out.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/devise/controllers/sign_in_out.rb b/lib/devise/controllers/sign_in_out.rb index 2d38ab23..b0e7b939 100644 --- a/lib/devise/controllers/sign_in_out.rb +++ b/lib/devise/controllers/sign_in_out.rb @@ -6,7 +6,10 @@ module Devise # Included by default in all controllers. module SignInOut # Return true if the given scope is signed in session. If no scope given, return - # true if any scope is signed in. Does not run authentication hooks. + # 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)` def signed_in?(scope=nil) [scope || Devise.mappings.keys].flatten.any? do |_scope| warden.authenticate?(scope: _scope)