Class: MainController

Inherits:
ApplicationController show all
Defined in:
app/controllers/main_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_route, #current_ability, #set_current_user

Instance Method Details

#check_loginObject



7
8
9
10
11
# File 'app/controllers/main_controller.rb', line 7

def 
  if @current_user && @current_user.freezed==0
    redirect_to "/"
  end
end

#createObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/main_controller.rb', line 30

def create
  @member=Member.where(:name => params[:member][:name]).first
  if @member
    password = Member.getmd5(params[:member][:password])
    if @member.password == password
      if @member.freezed==0
        session[:member_id] = @member.id
        redirect_to "/" and return
      else
        redirect_to :back, alert: "当前用户已经冻结不能登录"
      end
    else
      flash[:alert] = "密码错误"
      redirect_to :back
    end
  else
    @member=Member.new
    flash[:alert] = "用户名不存在"
    redirect_to :back
  end
end

#indexObject



4
5
# File 'app/controllers/main_controller.rb', line 4

def index
end

#logoutObject

退出登录汤建华



54
55
56
57
58
59
# File 'app/controllers/main_controller.rb', line 54

def logout
  if session[:member_id]
    session[:member_id]=nil
  end
  redirect_to "/main/new"
end

#newObject

登录页汤建华



25
26
27
28
# File 'app/controllers/main_controller.rb', line 25

def new
  @member= Member.new
  render layout: nil
end

#winceObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/main_controller.rb', line 13

def wince
  if !session[:member_id] || !session[:wince]
    session[:wince] = 1
    @member= Member.new
    render layout: nil
  else
    redirect_to search_order_logistics_path
  end
end