Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- prepend_before_filter(:preprocessRequest)
- # Anything we want to happen before a request is handled.
- def preprocessRequest()
- # If the request is a POST with a login attempt...
- if((request.post?) && (params[:commit] == "Login!") && (params[:User]))
- require("digest")
- params[:User][:passwordMD5] = Digest::MD5.hexdigest(params[:User][:passwordMD5])
- @user = User.find_by_eMail_and_passwordMD5(params[:User][:eMail], params[:User][:passwordMD5])
- params[:User][:passwordMD5] = nil
- # If the login succeeded, @user will be an instance of User.
- if(@user.kind_of?(User))
- flash[:notice] = "You have sucessfully logged in! Your current user information appears on the left side of the page."
- # The login failed, re-populate with the email address.
- else
- @user = User.create(params[:User])
- flash[:formErrors] = @user.errors
- end
Add Comment
Please, Sign In to add comment