Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private
- def login_as_trial_user
- #I don't want to use the method form here, I want it in app_controller, and I want using session[:session_id]
- #instead of rand and shit
- name = "anonymous_#{rand}_#{Time.now}_#{rand}"
- if User.find_by_username(name)
- UserSession.create(User.find_by_username(name),true)
- else
- guest_role = User.create(:username => name, :password => name, :password_confirmation => name, :role => "guest", :email => "change@this.com")
- UserSession.create(guest_role, true)
- end
- @current_user_session = UserSession.find
- guest_role
- end
- def require_login
- login_as_trial_user unless current_user_session
- end
Add Comment
Please, Sign In to add comment