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

Auto redirect on login page #175

Merged
merged 1 commit into from
Nov 14, 2022
Merged

Conversation

daniel-illi
Copy link
Member

closes #59739

@daniel-illi daniel-illi force-pushed the feature/auto-redirect-login-59739 branch 2 times, most recently from d9a93f2 to e1e286a Compare September 21, 2022 06:41
Comment on lines 13 to 33
def local_auth?
Settings.auth.db.active
end

def omniauth_providers
Settings.auth&.omniauth&.map(&:second)&.map(&:active)
end

def single_omniauth_provider?
omniauth_providers&.one?
end

def auto_login_disabled?
ActiveRecord::Type::Boolean.new.deserialize(params[:prevent_auto_login]) || false
end

def auto_redirect?
!auto_login_disabled? && !local_auth? && single_omniauth_provider?
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduction of the double negatives

Suggested change
def local_auth?
Settings.auth.db.active
end
def omniauth_providers
Settings.auth&.omniauth&.map(&:second)&.map(&:active)
end
def single_omniauth_provider?
omniauth_providers&.one?
end
def auto_login_disabled?
ActiveRecord::Type::Boolean.new.deserialize(params[:prevent_auto_login]) || false
end
def auto_redirect?
!auto_login_disabled? && !local_auth? && single_omniauth_provider?
end
def no_local_auth?
!Settings.auth.db.active
end
def omniauth_providers_active
Settings.auth&.omniauth&.map(&:second)&.map(&:active)
end
def single_omniauth_provider?
omniauth_providers_active&.one?
end
def auto_login_enabled?
return true unless prevent = params[:prevent_auto_login]
!ActiveRecord::Type::Boolean.new.deserialize(prevent)
end
def auto_redirect?
auto_login_enabled? && no_local_auth? && single_omniauth_provider?
end

@daniel-illi daniel-illi force-pushed the feature/auto-redirect-login-59739 branch from e1e286a to 1022337 Compare November 14, 2022 13:58
@daniel-illi daniel-illi merged commit 50ff026 into master Nov 14, 2022
@daniel-illi daniel-illi deleted the feature/auto-redirect-login-59739 branch November 14, 2022 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants