-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating redirect for initial user creation per #65
- Loading branch information
Showing
2 changed files
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
class ApplicationController < ActionController::Base | ||
protect_from_forgery | ||
before_filter :set_locale | ||
before_filter :check_for_initial_install | ||
|
||
def set_locale | ||
if user_signed_in? && current_user.locale != "" | ||
|
@@ -9,4 +10,12 @@ def set_locale | |
|
||
I18n.locale = session[:locale] || I18n.default_locale | ||
end | ||
|
||
#If there are no users defined yet, redirect to create the first admin user | ||
def check_for_initial_install | ||
if User.all.empty? | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
augustf
Author
Member
|
||
redirect_to new_user_registration_path | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm concerned over the latency implications of a User.all.empty? check being executed on every page. The longer term fix is probably to move this into a setting (setup_complete) which we know we'll cache heavily in the future.
A short-term measure could first check if a user is logged in, since a logged in user means we already have users in the system.