[Q&A] What is auth.winning_strategy and when it is nil?
truongnmt opened this issue · comments
Truong Nguyen commented
I have a question about this LOD:
def detect_strategy(auth)
strategy = auth.env["omniauth.auth"]["provider"] if auth.env["omniauth.auth"]
strategy ||= auth.winning_strategy.class.name.split("::").last.underscore if auth.winning_strategy
strategy ||= "database_authenticatable"
strategy
end
What and when auth.winning_strategy
will be nil? 🤔
Andrew Kane commented
Hey @truongnmt, strategies are a Warden concept. https://github.com/wardencommunity/warden/wiki/strategies
The winning strategy is the one that was selected for authentication. I can't recall which cases it's nil.
Truong Nguyen commented
I'm wondering on the condition if auth.winning_strategy
, can auth.winning_strategy
be nil? Hmm I'm skeptical..
Andrew Kane commented
Yes, it can 100% be nil
, or else the method wouldn't be written that way. I just can't recall the exact situations. Should have left a comment...