---
developer: letmein
maintain a yaml file that look like above where developer is the username and letmein is the password
Signin
Create a form that generate a parameter called username, store the username in the session[:username] if the username and password are valid.
Signout
session.delete(:username)
To determine whether to allow user to perform certain action, create a method
def require_signed_in_user
unless session.key?(:username) # which means whether there is a key name after 'username'
session[:message] = "You must be logged in to do that."
redirect "/"
end
end
Then put into whichever path that requires user login .
developer: letmein
maintain a yaml file that look like above where developer is the username and letmein is the password
Signin
Create a form that generate a parameter called username, store the username in the session[:username] if the username and password are valid.
Signout
session.delete(:username)
To determine whether to allow user to perform certain action, create a method
def require_signed_in_user
unless session.key?(:username) # which means whether there is a key name after 'username'
session[:message] = "You must be logged in to do that."
redirect "/"
end
end
Then put into whichever path that requires user login .
Comments
Post a Comment