Last active
December 11, 2015 01:19
-
-
Save aalvesjr/4522323 to your computer and use it in GitHub Desktop.
Create em sessions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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