Sha256: f685d622dc0f0bfe865f6a5e7a35bb781261ac769a0acc59ef52d421c1c585e2

Contents?: true

Size: 951 Bytes

Versions: 2

Compression:

Stored size: 951 Bytes

Contents

require_dependency "cadenero/application_controller"

module Cadenero::V1
  class Account::SessionsController < Cadenero::ApplicationController
    def create
      Rails.logger.info "params: #{params}"
      if env['warden'].authenticate(:password, :scope => :user)
        render json: current_user, status: 201
      else
        render json: {errors: {user:["Invalid email or password"]}}, status: 422
      end
    end
    def delete
      user = Cadenero::User.find_by_id(params[:id])
      Rails.logger.info "id: #{params[:id]}"
      Rails.logger.info "user: #{user.to_json}"
      Rails.logger.info "current_user.id: #{current_user}"
      Rails.logger.info "user_signed_in?: #{user_signed_in?}"
      if user_signed_in? 
        env['warden'].logout(:user)
        render json: {message: "Successful logout"}, status: 201
      else
        render json: {message: "Unsuccessful logout user with id"}, status: 401
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cadenero-0.0.2.a2 app/controllers/cadenero/v1/account/sessions_controller.rb
cadenero-0.0.2.a1 app/controllers/cadenero/v1/account/sessions_controller.rb