add login
This commit is contained in:
parent
eb8e6a64b4
commit
1b7b26ee06
@ -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
|
||||
|
@ -1,6 +1,8 @@
|
||||
class HomeController < ApplicationController
|
||||
|
||||
before_action :require_login
|
||||
|
||||
def index
|
||||
|
||||
@current_dir = "/mnt"
|
||||
file_directory(@current_dir)
|
||||
end
|
||||
|
@ -1,4 +1,6 @@
|
||||
class NodeController < ApplicationController
|
||||
before_action :require_login
|
||||
|
||||
def index
|
||||
@hosts = Array.new
|
||||
@nodes = Node.all.order("id asc")
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,5 @@
|
||||
class VolumeController < ApplicationController
|
||||
before_action :require_login
|
||||
|
||||
def index
|
||||
file_directory("/mnt")
|
||||
|
@ -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
|
@ -10,7 +10,7 @@
|
||||
<li class="">
|
||||
<a href="javascript:;" class="user-profile" aria-expanded="false">
|
||||
<span class="glyphicon glyphicon-user" aria-hidden="true"></span>
|
||||
Hello, admin!
|
||||
Hello, <%=current_user.username%> admin!
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -20,8 +20,9 @@
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input type="text" class="form-control" placeholder="Username" required="" />
|
||||
<%= f.text_field :username, autofocus: true , class: "form-control", placeholder: "Username", required: ""%>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= f.email_field :email, autofocus: true , class: "form-control", placeholder: "Email", required: ""%>
|
||||
</div>
|
||||
|
@ -43,8 +43,8 @@
|
||||
<div class="clearfix"></div>
|
||||
<br />
|
||||
<div>
|
||||
<h1><i class="fa fa-paw" style="font-size: 26px;"></i> Gentelella Alela!</h1>
|
||||
<p>©2015 All Rights Reserved. Gentelella Alela! is a Bootstrap 3 template. Privacy and Terms</p>
|
||||
<h1><i class="fa fa-cloud" style="font-size: 26px;"></i> Gluster Web Interface</h1>
|
||||
<p>©2016 OSS WORLD CHALLENGE. <br>Gluster Web Interface by WEB</p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user