Sha256: 90ed5a9622b03ffd6b199e1cf9eeaa34874108b56cd16073766e1bcec1dd24fd

Contents?: true

Size: 541 Bytes

Versions: 10

Compression:

Stored size: 541 Bytes

Contents

class SessionsController < ApplicationController
  skip_before_action :authenticate, except: :destroy

  def create
    @<%= singular_table_name %> = <%= class_name %>.find_by_email(params[:email])

    if @<%= singular_table_name %>.try(:authenticate, params[:password])
      render json: { session_token: @<%= singular_table_name %>.session_token }
    else
      render json: { error: "Invalid session token" }, status: :unauthorized
    end
  end

  def destroy
    Current.<%= singular_table_name %>.regenerate_session_token
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
authentication-zero-0.0.15 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
authentication-zero-0.0.14 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
authentication-zero-0.0.13 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
authentication-zero-0.0.12 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
authentication-zero-0.0.11 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
authentication-zero-0.0.10 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
authentication-zero-0.0.9 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
authentication-zero-0.0.8 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
authentication-zero-0.0.7 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt
authentication-zero-0.0.6 lib/generators/authentication/templates/controllers/api/sessions_controller.rb.tt