Class: RivetCms::SetupController
- Inherits:
-
AuthController
- Object
- ApplicationController
- AuthController
- RivetCms::SetupController
- Defined in:
- app/controllers/rivet_cms/setup_controller.rb
Overview
First-run screen: with no users at all, the first visit creates the owner account. Gone the moment one user exists; never a registration form.
Outside development/test a fresh deployment cannot be claimed by whoever finds it first: setup demands a code that is written to the server log (or configured via RivetCms.setup_code), so claiming requires server access. The Jenkins initial-password pattern.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/rivet_cms/setup_controller.rb', line 17 def create unless setup_code_valid? return redirect_to setup_path, inertia: { errors: { base: [ "That setup code is not right. It is printed in the server log." ] } } end if params[:password].blank? # has_secure_password ignores an empty string entirely, which would # otherwise create a passwordless owner and sign them in return redirect_to setup_path, inertia: { errors: { password: [ "can't be blank" ] } } end user = users.new(user_params) if user.save sign_in(user) redirect_to root_path, notice: "Welcome to RivetCMS" else redirect_to setup_path, inertia: { errors: user.errors } end end |
#new ⇒ Object
12 13 14 15 |
# File 'app/controllers/rivet_cms/setup_controller.rb', line 12 def new log_setup_code render inertia: "Auth/Setup", props: { submit_path: setup_path, requires_code: RivetCms.setup_code_required? } end |