diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 42ff39c..86acea4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,6 +3,14 @@ class ApplicationController < ActionController::Base # For APIs, you may want to use :null_session instead. # protect_from_forgery with: :exception + + def require_login + unless user_signed_in? + flash[:error] = "Please, Login required to use the service." + redirect_to "/users/sign_in" # halts request cycle + end + end + def get_conf config = Hash.new one_node = Node.take diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1b0f11b..72f9e47 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,6 +1,8 @@ class HomeController < ApplicationController - + before_action :require_login + def index + @current_dir = "/mnt" file_directory(@current_dir) end diff --git a/app/controllers/node_controller.rb b/app/controllers/node_controller.rb index 02bbf3f..6e167b1 100644 --- a/app/controllers/node_controller.rb +++ b/app/controllers/node_controller.rb @@ -1,4 +1,6 @@ class NodeController < ApplicationController + before_action :require_login + def index @hosts = Array.new @nodes = Node.all.order("id asc") diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 8ebae4d..617c38b 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -1,6 +1,7 @@ class Users::RegistrationsController < Devise::RegistrationsController +before_action :configure_sign_up_params, only: [:create] layout "login_pages" -# before_action :configure_sign_up_params, only: [:create] + # before_action :configure_account_update_params, only: [:update] # GET /resource/sign_up @@ -9,9 +10,9 @@ class Users::RegistrationsController < Devise::RegistrationsController # end # POST /resource - def create - super - end + #def create + # super + # end # GET /resource/edit # def edit @@ -40,9 +41,9 @@ class Users::RegistrationsController < Devise::RegistrationsController # protected # If you have extra params to permit, append them to the sanitizer. - # def configure_sign_up_params - # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute]) - # end + def configure_sign_up_params + devise_parameter_sanitizer.permit(:sign_up, keys: [:username, :email, :password, :password_confirmation]) + end # If you have extra params to permit, append them to the sanitizer. # def configure_account_update_params diff --git a/app/controllers/volume_controller.rb b/app/controllers/volume_controller.rb index 86d380f..272835a 100644 --- a/app/controllers/volume_controller.rb +++ b/app/controllers/volume_controller.rb @@ -1,4 +1,5 @@ class VolumeController < ApplicationController + before_action :require_login def index file_directory("/mnt") diff --git a/app/models/user.rb b/app/models/user.rb index c822027..654ae78 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,3 +4,10 @@ class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable end + +class User::ParameterSanitizer < Devise::ParameterSanitizer + def initialize(*) + super + permit(:sign_up, keys: [:username, :email]) + end +end \ No newline at end of file diff --git a/app/views/partials/_topnav.html.erb b/app/views/partials/_topnav.html.erb index 0659e46..dfa4e37 100644 --- a/app/views/partials/_topnav.html.erb +++ b/app/views/partials/_topnav.html.erb @@ -10,7 +10,7 @@
©2015 All Rights Reserved. Gentelella Alela! is a Bootstrap 3 template. Privacy and Terms
+©2016 OSS WORLD CHALLENGE.
Gluster Web Interface by WEB