Commit 8844c51b authored by Fabricio Jose de Oliveira Ceschin's avatar Fabricio Jose de Oliveira Ceschin
Browse files

Change json error flag

parent 5907f90e
# include Devise::Controllers::InternalHelpers
class App::Json::CidadaosController < App::Json::AppController
def index
end
# /app/json/cidadao/login?cpf=[:cpf]&senha=[:password]
def login
# build_resource
resource = Cidadao.where(:cpf => params[:cpf])
puts params[:cidadao]
if resource.size <= 0
render :json=> {:error=>true, :message=>"CPF ou senha inválida."}
#redirect_to :action => "login", :cpf => "087.461.987-31"
render :json=> {:sucess=>false, :message=>"CPF ou senha inválida."}
else
cidadao = resource.first
if cidadao.valid_password? params[:password]
cidadao.regenerate_token
render :json=> {:sucess => true, :message=>"Bem vindo, #{cidadao.nome}", :token => cidadao.token}
else
render :json=> {:error=>true, :message=>"CPF ou senha inválida."}
render :json=> {:sucess=>false, :message=>"CPF ou senha inválida."}
end
end
end
......@@ -25,26 +22,6 @@ class App::Json::CidadaosController < App::Json::AppController
private
end
# # encoding: UTF-8
# module App
# module Json
# class CidadaosController < ApplicationController
# include Devise::Controllers::InternalHelpers
# respond_to :json
# def login
# build_resource
# resource = Cidadao.where(:cpf => params[:cpf])
# if resource.size <= 0
# render :json=> {:error=>true, :message=>"CPF ou senha inválida."}
# end
# end
# # Actions omitten
# end
# end
# end
# # class CidadaosController < ApplicationController
# # before_action :authenticate_cidadao!
# # before_action :situacao_bloqueio_cidadao, :only => [:schedule_agreement,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment