Sha256: 650d0714e5e3ded23dcef8bbde81470db9fdd8785ab2d76015bede0ca5c0837f

Contents?: true

Size: 729 Bytes

Versions: 5

Compression:

Stored size: 729 Bytes

Contents

# frozen_string_literal: true

require 'ditty/controllers/application_controller'
require 'ditty/models/role'
require 'ditty/models/user'
require 'ditty/services/settings'

module Ditty
  class MainController < ApplicationController
    set track_actions: true

    before '/' do
      return if User.where(roles: Role.find_or_create(name: 'super_admin')).count.positive?

      flash[:info] = 'Please register the super admin user.'
      redirect "#{settings.map_path}/auth/register"
    end

    # Home Page
    get '/' do
      home_page = Services::Settings['ditty.home_page']
      redirect "#{settings.map_path}#{home_page}" if home_page

      authenticate!
      haml :index, locals: { title: 'Home' }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ditty-0.11.1 lib/ditty/controllers/main_controller.rb
ditty-0.10.2 lib/ditty/controllers/main_controller.rb
ditty-0.10.1 lib/ditty/controllers/main_controller.rb
ditty-0.9.1 lib/ditty/controllers/main_controller.rb
ditty-0.9.0 lib/ditty/controllers/main_controller.rb