Code cleanup.
This commit is contained in:
parent
b870b8208b
commit
e881900093
3 changed files with 7 additions and 85 deletions
|
@ -99,43 +99,19 @@ class ApplicationController < ActionController::Base
|
|||
# logging out removes it.
|
||||
def current_user
|
||||
@_current_user ||= session[:user_id] &&
|
||||
User.find_by_id(session[:user_id])
|
||||
User.find_by_id( session[:user_id] )
|
||||
end
|
||||
|
||||
# def authenticate
|
||||
# unless current_user
|
||||
# respond_to do |format|
|
||||
# format.html {
|
||||
# flash[:notice] = "You're not logged in!"
|
||||
# store_location
|
||||
# redirect_to :login
|
||||
# }
|
||||
# format.json {
|
||||
# render :json => { :error => 'login required' }, :status => :unauthorized
|
||||
# }
|
||||
# end
|
||||
# return false
|
||||
# end
|
||||
# end
|
||||
# def store_location
|
||||
# session[:return_to] = request.url
|
||||
# end
|
||||
# def redirect_back_or_default(default)
|
||||
# redirect_to(session[:return_to] || default)
|
||||
# session[:return_to] = nil
|
||||
# end
|
||||
def authentication_check
|
||||
logger.debug 'authentication_check'
|
||||
# logger.debug session.inspect
|
||||
|
||||
# check http basic auth
|
||||
authenticate_with_http_basic do |user, password|
|
||||
logger.debug 'http basic auth check'
|
||||
# logger.debug session.inspect
|
||||
logger.debug user
|
||||
logger.debug password
|
||||
userdata = User.where(:login => user).first
|
||||
# logger.debug userdata.inspect
|
||||
|
||||
# logger.debug user
|
||||
# logger.debug password
|
||||
userdata = User.where( :login => user ).first
|
||||
message = ''
|
||||
if !userdata
|
||||
message = 'authentication failed, user'
|
||||
|
@ -154,18 +130,14 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
return true
|
||||
# return true
|
||||
# request_http_basic_authentication
|
||||
end
|
||||
|
||||
# logger.debug 'session check'
|
||||
# logger.debug session.inspect
|
||||
# session[:user_id] = 2
|
||||
if !session[:user_id]
|
||||
# = userdata.id
|
||||
logger.debug '!session user_id'
|
||||
# session[:name] = 'lol'
|
||||
logger.debug session.inspect
|
||||
# logger.debug session.inspect
|
||||
message = 'no valid session, user_id'
|
||||
respond_to do |format|
|
||||
format.json {
|
||||
|
@ -176,10 +148,9 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
# check session auth
|
||||
# logger.debug request.env.inspect
|
||||
# return 1231
|
||||
# request_http_basic_authentication
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
# Sets the current user into a named Thread location so that it can be accessed
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
module Account
|
||||
class Outbound < ActiveRecord::Base
|
||||
self.table_name = 'account_outbound'
|
||||
end
|
||||
|
||||
class Inbound < ActiveRecord::Base
|
||||
self.table_name = 'account_inbound'
|
||||
end
|
||||
|
||||
class InboundFilter < ActiveRecord::Base
|
||||
self.table_name = 'account_inbound_filter'
|
||||
end
|
||||
|
||||
end
|
|
@ -151,37 +151,6 @@ class CreateTicket < ActiveRecord::Migration
|
|||
add_index :overviews_groups, [:overview_id]
|
||||
add_index :overviews_groups, [:group_id]
|
||||
|
||||
create_table :account_inbounds do |t|
|
||||
t.references :group, :null => true
|
||||
t.column :login, :string, :limit => 250, :null => false
|
||||
t.column :password, :string, :limit => 250, :null => false
|
||||
t.column :host, :string, :limit => 250, :null => false
|
||||
t.column :account_type, :string, :limit => 20, :null => false
|
||||
t.column :trusted, :boolean, :null => false, :default => false
|
||||
t.column :active, :boolean, :null => false, :default => true
|
||||
t.column :note, :string, :limit => 250, :null => true
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :account_outbounds do |t|
|
||||
t.column :realname, :string, :limit => 250, :null => false
|
||||
t.column :address, :string, :limit => 250, :null => false
|
||||
t.column :account_type, :string, :limit => 20, :null => false
|
||||
t.column :login, :string, :limit => 250, :null => true
|
||||
t.column :password, :string, :limit => 250, :null => true
|
||||
t.column :host, :string, :limit => 250, :null => true
|
||||
t.column :active, :boolean, :null => false, :default => true
|
||||
t.column :note, :string, :limit => 250, :null => true
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :account_inbound_filters do |t|
|
||||
t.column :name, :string, :limit => 250, :null => false
|
||||
t.column :key, :string, :limit => 250, :null => false
|
||||
t.column :value, :string, :limit => 250, :null => false
|
||||
end
|
||||
add_index :account_inbound_filters, [:name]
|
||||
|
||||
create_table :triggers do |t|
|
||||
t.column :name, :string, :limit => 250, :null => false
|
||||
t.column :key, :string, :limit => 250, :null => false
|
||||
|
@ -192,7 +161,6 @@ class CreateTicket < ActiveRecord::Migration
|
|||
add_index :triggers, [:value]
|
||||
|
||||
create_table :notifications do |t|
|
||||
t.references :account_outbounds, :null => false
|
||||
t.column :subject, :string, :limit => 250, :null => false
|
||||
t.column :body, :string, :limit => 8000, :null => false
|
||||
t.column :content_type, :string, :limit => 250, :null => false
|
||||
|
@ -245,8 +213,5 @@ class CreateTicket < ActiveRecord::Migration
|
|||
drop_table :ticket_priorities
|
||||
drop_table :ticket_states
|
||||
drop_table :ticket_state_types
|
||||
drop_table :account_inbounds
|
||||
drop_table :account_inbound_filters
|
||||
drop_table :account_outbounds
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue