Skip to content

Instantly share code, notes, and snippets.

@aalvesjr
Last active December 11, 2015 01:19
Show Gist options
  • Select an option

  • Save aalvesjr/4522323 to your computer and use it in GitHub Desktop.

Select an option

Save aalvesjr/4522323 to your computer and use it in GitHub Desktop.
Create em sessions
def create
reset_session
# O ideal seria extrair essa parte de autenticação
# para uma classe que responsavel por isso
user = User.find_by_email(params[:email])
user ||= User.new
password_encripted = Digest::SHA1.hexdigest(params[:password])
if user.password == password_encripted
session[:user_id] = user.id
redirect_to dashboard_path#, :notice => "Logado com sucesso"
else
flash.now[:notice] = "Usuário ou Senha incorretos, tente novamente."
render :new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment