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 @@
  • diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb index bd63e02..9b36a27 100644 --- a/app/views/users/registrations/new.html.erb +++ b/app/views/users/registrations/new.html.erb @@ -20,8 +20,9 @@
    - + <%= f.text_field :username, autofocus: true , class: "form-control", placeholder: "Username", required: ""%>
    +
    <%= f.email_field :email, autofocus: true , class: "form-control", placeholder: "Email", required: ""%>
    diff --git a/app/views/users/sessions/new.html.erb b/app/views/users/sessions/new.html.erb index 20b81f9..8b86e42 100644 --- a/app/views/users/sessions/new.html.erb +++ b/app/views/users/sessions/new.html.erb @@ -43,8 +43,8 @@

    -

    Gentelella Alela!

    -

    ©2015 All Rights Reserved. Gentelella Alela! is a Bootstrap 3 template. Privacy and Terms

    +

    Gluster Web Interface

    +

    ©2016 OSS WORLD CHALLENGE.
    Gluster Web Interface by WEB

    <% end %> diff --git a/db/migrate/20160819061449_devise_create_users.rb b/db/migrate/20160819061449_devise_create_users.rb index 9200e8b..6f33f3b 100644 --- a/db/migrate/20160819061449_devise_create_users.rb +++ b/db/migrate/20160819061449_devise_create_users.rb @@ -4,6 +4,7 @@ class DeviseCreateUsers < ActiveRecord::Migration ## Database authenticatable t.string :email, null: false, default: "" t.string :encrypted_password, null: false, default: "" + t.string :username ## Recoverable t.string :reset_password_token diff --git a/db/schema.rb b/db/schema.rb index 1b31bfa..2675a25 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -25,6 +25,7 @@ ActiveRecord::Schema.define(version: 20160920111650) do create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false + t.string "username" t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at"