Class: Auth::LoginController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/auth/login_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/auth/login_controller.rb', line 19

def create
  if @user && @user.can_login?(params)
     @user

    respond_to do |format|
      format.html { redirect_back_or_default }
      format.js
    end
  else
    if @user
      flash[:error] = @user.errors.messages.values.flatten.join(' ')
    else
      flash[:error] = t('errors.messages.wrong_name_or_password')
    end

    respond_to do |format|
      format.html { redirect_back fallback_location:  }
      format.js { render :new }
    end
  end

end

#destroyObject



42
43
44
45
# File 'app/controllers/auth/login_controller.rb', line 42

def destroy
  logout
  redirect_to root_url
end

#newObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/auth/login_controller.rb', line 4

def new
  @user = User.new
  store_location request.referer if request.referer.present?

  unless request.xhr? || params[:form_id]
    @local = true
  end

  respond_to do |format|
    format.html.phone
    format.html
    format.js
  end
end