Class: SessionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/authkit/templates/app/controllers/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/generators/authkit/templates/app/controllers/sessions_controller.rb', line 6

def create
  if user && user.authenticate(params[:password])
    (user)
    respond_to do |format|
      format.json { head :no_content }
      format.html { redirect_back_or_default }
    end
  else
    respond_to do |format|
      format.json { render json: { errors: ["Invalid user name or password"], status: "error" }, status: 422 }
      format.html {
        flash.now[:error] = "Invalid user name or password"
        render :new
      }
    end
  end
end

#destroyObject

Logout



25
26
27
28
29
30
31
# File 'lib/generators/authkit/templates/app/controllers/sessions_controller.rb', line 25

def destroy
  logout
  respond_to do |format|
    format.json { head :no_content }
    format.html { redirect_to root_path }
  end
end

#newObject

Login



3
4
# File 'lib/generators/authkit/templates/app/controllers/sessions_controller.rb', line 3

def new
end