More tests
Only one user can sign in - until this becomes multiuser
This commit is contained in:
parent
ae7846e46e
commit
4c63480a1f
17
app/controllers/registrations_controller.rb
Normal file
17
app/controllers/registrations_controller.rb
Normal file
@ -0,0 +1,17 @@
|
||||
class RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
before_action :one_user_registered?, only: [:new, :create]
|
||||
|
||||
protected
|
||||
|
||||
def one_user_registered?
|
||||
if User.count == 1
|
||||
if user_signed_in?
|
||||
redirect_to root_path
|
||||
else
|
||||
redirect_to new_user_session_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@ -23,3 +23,5 @@
|
||||
<%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %><br />
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
@ -31,7 +31,6 @@
|
||||
<hr/>
|
||||
<h3>To-Do (In order of importance):</h3>
|
||||
<ul>
|
||||
<li>Blocking Sign-up at Routes level</li>
|
||||
<li>Tests for controllers and integration</li>
|
||||
<li>2FA</li>
|
||||
</ul>
|
||||
|
||||
@ -2,10 +2,11 @@ Rails.application.routes.draw do
|
||||
|
||||
resources :domains do
|
||||
resources :credentials, only: [ :new, :create, :edit, :update, :destroy]
|
||||
resources :virtuals
|
||||
resources :virtuals, only: [ :new, :create, :edit, :update, :destroy]
|
||||
end
|
||||
|
||||
devise_for :users
|
||||
devise_for :users, controllers: { registrations: "registrations" }
|
||||
|
||||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||
|
||||
# Defines the root path route ("/")
|
||||
|
||||
@ -3,6 +3,7 @@ require "test_helper"
|
||||
class VirtualsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@virtual = virtuals(:one)
|
||||
@domain = doamins(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user