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

Check if token is nil

parent 8844c51b
......@@ -9,13 +9,15 @@ class App::Json::CidadaosController < App::Json::AppController
if resource.size <= 0
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=> {:sucess=>false, :message=>"CPF ou senha inválida."}
end
cidadao = resource.first
if cidadao.valid_password? params[:password]
if !cidadao.token
cidadao.regenerate_token
end
render :json=> {:sucess => true, :message=>"Bem vindo, #{cidadao.nome}", :token => cidadao.token}
else
render :json=> {:sucess=>false, :message=>"CPF ou senha inválida."}
end
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