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

Check if authtoken is valid

parent ce568076
......@@ -5,7 +5,6 @@ class App::Json::CidadaosController < App::Json::AppController
# /app/json/cidadao/login?cpf=[:cpf]&senha=[:password]
def login
resource = Cidadao.where(:cpf => params[:cpf])
puts params[:cidadao]
if resource.size <= 0
render :json=> {:sucess=>false, :message=>"CPF ou senha inválida."}
else
......@@ -21,6 +20,16 @@ class App::Json::CidadaosController < App::Json::AppController
end
end
# /app/json/cidadao/authtoken?token=[:token]
def authtoken
resource = Cidadao.where(:token => params[:token])
if resource.size <= 0
render :json=> {:sucess=>false, :message=>"Sessão expirada."}
else
render :json=> {:sucess => true}
end
end
private
end
......
......@@ -159,6 +159,7 @@ Agendador::Application.routes.draw do
# devise_scope :cidadao do
resources :cidadaos
get "cidadao/login/", :to => 'cidadaos#login'
get "cidadao/authtoken/", :to => 'cidadaos#authtoken'
# delete "/sign_out", :to => 'session#destroy'
# end
end
......
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