Created
May 6, 2011 07:37
-
-
Save Spaceghost/958565 to your computer and use it in GitHub Desktop.
A snippet of Monoceros code
This file contains 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
<%= form_tag monoceros_sessions_path do %> | |
<p> | |
<%= label_tag :username_or_email %><br /> | |
<%= text_field_tag :login, params[:login] %> | |
</p> | |
<p> | |
<%= label_tag :password %><br /> | |
<%= password_field_tag :password %> | |
</p> | |
<p class="button"><%= submit_tag "Log in" %></p> | |
<% end %> |
This file contains 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
class Monoceros::Authentication::SessionsController < ApplicationController | |
def new | |
end | |
def create | |
user = User.authenticate(params[:login].downcase, params[:password]) | |
if user | |
session[:user_id] = user.id | |
redirect_to monoceros_dashboard_url, :notice => "Logged in!" | |
else | |
flash.now.alert = "Invalid email or password" | |
render "new" | |
end | |
end | |
def destroy | |
session[:user_id] = nil | |
redirect_to monoceros_root_url, :notice => "Logged out!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment