mirror of
https://github.com/we-promise/sure.git
synced 2026-04-08 06:44:52 +00:00
* Add configuration and logic for dynamic SSO provider support and stricter JIT account creation - Introduced `config/auth.yml` for centralized auth configuration and documentation. - Added support for multiple SSO providers, including Google, GitHub, and OpenID Connect. - Implemented stricter JIT SSO account creation modes (`create_and_link` vs `link_only`). - Enabled optional restriction of JIT creation by allowed email domains. - Enhanced OmniAuth initializer for dynamic provider setup and better configurability. - Refined login UI to handle local login disabling and emergency super-admin override. - Updated account creation flow to respect JIT mode and domain checks. - Added tests for SSO account creation, login form visibility, and emergency overrides. # Conflicts: # app/controllers/sessions_controller.rb * remove non-translation * Refactor authentication views to use translation keys and update locale files - Extracted hardcoded strings in `oidc_accounts/link.html.erb` and `sessions/new.html.erb` into translation keys for better localization support. - Added missing translations for English and Spanish in `sessions` and `oidc_accounts` locale files. * Enhance OmniAuth provider configuration and refine local login override logic - Updated OmniAuth initializer to support dynamic provider configuration with `name` and scoped parameters for Google and GitHub. - Improved local login logic to enforce stricter handling of super-admin override when local login is disabled. - Added test for invalid super-admin override credentials. * Document Google sign-in configuration for local development and self-hosted environments --------- Co-authored-by: Josh Waldrep <joshua.waldrep5+github@gmail.com>
52 lines
1.2 KiB
Ruby
52 lines
1.2 KiB
Ruby
class PasswordResetsController < ApplicationController
|
|
skip_authentication
|
|
|
|
layout "auth"
|
|
|
|
before_action :ensure_password_resets_enabled
|
|
before_action :set_user_by_token, only: %i[edit update]
|
|
|
|
def new
|
|
end
|
|
|
|
def create
|
|
if (user = User.find_by(email: params[:email]))
|
|
PasswordMailer.with(
|
|
user: user,
|
|
token: user.generate_token_for(:password_reset)
|
|
).password_reset.deliver_later
|
|
end
|
|
|
|
redirect_to new_password_reset_path(step: "pending")
|
|
end
|
|
|
|
def edit
|
|
@user = User.new
|
|
end
|
|
|
|
def update
|
|
if @user.update(password_params)
|
|
redirect_to new_session_path, notice: t(".success")
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def ensure_password_resets_enabled
|
|
return if AuthConfig.password_features_enabled?
|
|
|
|
redirect_to new_session_path, alert: t("password_resets.disabled")
|
|
end
|
|
|
|
def set_user_by_token
|
|
@user = User.find_by_token_for(:password_reset, params[:token])
|
|
redirect_to new_password_reset_path, alert: t("password_resets.update.invalid_token") unless @user.present?
|
|
end
|
|
|
|
def password_params
|
|
params.require(:user).permit(:password, :password_confirmation)
|
|
end
|
|
end
|