Disable OmniAuth account creation if 'invite only'
This commit is contained in:
parent
d432798ff8
commit
acf147ef88
|
@ -28,6 +28,8 @@ class Users::OmniauthCallbacksController < ApplicationController
|
||||||
# Call the appropriate logic
|
# Call the appropriate logic
|
||||||
send("create_or_sign_on_user_using_#{provider}", request.env["omniauth.auth"])
|
send("create_or_sign_on_user_using_#{provider}", request.env["omniauth.auth"])
|
||||||
|
|
||||||
|
@data[:awaiting_approval] = true if invite_only?
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.json { render json: @data }
|
format.json { render json: @data }
|
||||||
|
@ -316,4 +318,9 @@ class Users::OmniauthCallbacksController < ApplicationController
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def invite_only?
|
||||||
|
SiteSetting.invite_only? && !@data[:authenticated]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,6 +32,17 @@ describe Users::OmniauthCallbacksController do
|
||||||
response.should be_success
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when 'invite only' site setting is enabled" do
|
||||||
|
before { SiteSetting.stubs(:invite_only?).returns(true) }
|
||||||
|
|
||||||
|
it 'informs the user they are awaiting approval' do
|
||||||
|
xhr :get, :complete, provider: 'twitter', format: :json
|
||||||
|
|
||||||
|
expect(
|
||||||
|
JSON.parse(response.body)['awaiting_approval']
|
||||||
|
).to be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'facebook' do
|
describe 'facebook' do
|
||||||
|
|
Loading…
Reference in New Issue