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
root :to => "sessions#login" | |
match "signup", :to => "users#new" | |
match "login", :to => "sessions#login" | |
match "logout", :to => "sessions#logout" | |
match "home", :to => "sessions#home" | |
match "profile", :to => "sessions#profile" | |
match "setting", :to => "sessions#setting" |
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
def logout | |
session[:user_id] = nil | |
redirect_to :action => 'login' | |
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
<h2 class='User_Header'> <%=@current_user.username%> Profile <h2> |
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
before_filter :save_login_state, :only => [:new, :create] |
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
before_filter :authenticate_user, :only => [:home, :profile, :setting] | |
before_filter :save_login_state, :only => [:login, :login_attempt] |
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
protected | |
def authenticate_user | |
if session[:user_id] | |
# set current user object to @current_user object variable | |
@current_user = User.find session[:user_id] | |
return true | |
else | |
redirect_to(:controller => 'sessions', :action => 'login') | |
return false | |
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
def login_attempt | |
authorized_user = User.authenticate(params[:username_or_email],params[:login_password]) | |
if authorized_user | |
session[:user_id] = authorized_user.id | |
flash[:notice] = "Wow Welcome again, you logged in as #{authorized_user.username}" | |
redirect_to(:action => 'home') | |
else | |
flash[:notice] = "Invalid Username or Password" | |
flash[:color]= "invalid" | |
render "login" |
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
session[:name]= "Azzurrio" |
NewerOlder