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

fix(signup): Use correct env var to check if signup is disabled #2256

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/services/users_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def login(email, password)
end

def register(email, password, organization_name)
if ENV.fetch('LAGO_SIGNUP_DISABLED', 'false') == 'true'
return result.not_allowed_failure!(code: 'signup disabled')
if ENV.fetch('LAGO_DISABLE_SIGNUP', 'false') == 'true'
return result.not_allowed_failure!(code: 'signup_disabled')
end

if User.exists?(email:)
Expand Down
6 changes: 3 additions & 3 deletions spec/services/users_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@

context 'when signup is disabled' do
before do
ENV['LAGO_SIGNUP_DISABLED'] = 'true'
ENV['LAGO_DISABLE_SIGNUP'] = 'true'
end

after do
ENV['LAGO_SIGNUP_DISABLED'] = nil
ENV['LAGO_DISABLE_SIGNUP'] = nil
end

it 'returns a not allowed error' do
result = user_service.register('email', 'password', 'organization_name')

aggregate_failures do
expect(result).not_to be_success
expect(result.error.message).to eq('signup disabled')
expect(result.error.message).to eq('signup_disabled')
end
end
end
Expand Down