mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Allow invites redemption with Omniauth providers.
This commit is contained in:
@@ -8,6 +8,7 @@ class InvitesController < ApplicationController
|
||||
skip_before_action :preload_json, except: [:show]
|
||||
skip_before_action :redirect_to_login_if_required
|
||||
|
||||
before_action :ensure_invites_allowed, only: [:show, :perform_accept_invitation]
|
||||
before_action :ensure_new_registrations_allowed, only: [:show, :perform_accept_invitation]
|
||||
before_action :ensure_not_logged_in, only: [:show, :perform_accept_invitation]
|
||||
|
||||
@@ -168,7 +169,8 @@ class InvitesController < ApplicationController
|
||||
name: params[:name],
|
||||
password: params[:password],
|
||||
user_custom_fields: params[:user_custom_fields],
|
||||
ip_address: request.remote_ip
|
||||
ip_address: request.remote_ip,
|
||||
session: session
|
||||
}
|
||||
|
||||
attrs[:email] =
|
||||
@@ -284,6 +286,12 @@ class InvitesController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def ensure_invites_allowed
|
||||
if SiteSetting.enable_discourse_connect || (!SiteSetting.enable_local_logins && Discourse.enabled_auth_providers.count == 0)
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_new_registrations_allowed
|
||||
unless SiteSetting.allow_new_registrations
|
||||
flash[:error] = I18n.t('login.new_registrations_disabled')
|
||||
|
||||
@@ -119,7 +119,12 @@ class Users::OmniauthCallbacksController < ApplicationController
|
||||
end
|
||||
|
||||
def invite_required?
|
||||
SiteSetting.invite_only?
|
||||
if SiteSetting.invite_only?
|
||||
path = Discourse.route_for(@origin)
|
||||
return true unless path
|
||||
return true if path[:controller] != "invites" && path[:action] != "show"
|
||||
!Invite.exists?(invite_key: path[:id])
|
||||
end
|
||||
end
|
||||
|
||||
def user_found(user)
|
||||
|
||||
@@ -447,8 +447,6 @@ class UsersController < ApplicationController
|
||||
elsif current_user&.staff?
|
||||
message = if SiteSetting.enable_discourse_connect
|
||||
I18n.t("invite.disabled_errors.discourse_connect_enabled")
|
||||
elsif !SiteSetting.enable_local_logins
|
||||
I18n.t("invite.disabled_errors.local_logins_disabled")
|
||||
end
|
||||
|
||||
render_invite_error(message)
|
||||
|
||||
Reference in New Issue
Block a user