Skip to content

Commit

Permalink
refactor: revert disable third-part oauth to login when disbale regis…
Browse files Browse the repository at this point in the history
…trations mode
  • Loading branch information
icyleaf committed Sep 27, 2024
1 parent 148a5b4 commit 9d7b05e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 11 deletions.
6 changes: 0 additions & 6 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
before_action :disable_registrations_mode unless Setting.registrations_mode

User.oauth_providers.each do |provider_name|
define_method(provider_name) do
omniauth_callback(provider_name)
Expand Down Expand Up @@ -52,8 +50,4 @@ def goback_path
omni_params = request.env['omniauth.params']
omni_params&['back'].presence || request.env['HTTP_REFERER'] || root_path
end

def disable_registrations_mode
redirect_to user_session_path, alert: t('devise.omniauth_callbacks.disabled')
end
end
2 changes: 1 addition & 1 deletion app/views/devise/shared/_links.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- if devise_mapping.omniauthable? && Setting.registrations_mode
- if devise_mapping.omniauthable?
.social-auth-links.mb-3.d-grid
- resource_class.oauth_providers.each do |provider|
- unless provider == :ldap
Expand Down
2 changes: 0 additions & 2 deletions config/locales/devise/devise.views.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ en:
danger_zone: Danger Zone
cancel_my_account: Delete account
unhappy: Do you really want to delete your account?
omniauth_callbacks:
disabled: Registration mode is closed. Please contact the administrator.
3 changes: 1 addition & 2 deletions config/locales/devise/devise.views.zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ zh-CN:
message: 由于多次登录失败,您的帐户已被锁定。
subject: 帐户解锁信息
omniauth_callbacks:
disabled: 系统关闭了注册功能,请联系管理员。
failure: 由于 %{reason},无法从%{kind}获得授权。
failure: 基于 %{reason},无法从%{kind}获得授权。
success: 成功地从%{kind}获得授权。
passwords:
edit:
Expand Down

0 comments on commit 9d7b05e

Please sign in to comment.