SHARE
TWEET

Untitled

a guest Apr 26th, 2018 206 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.   private
  3.   def login_as_trial_user
  4.     #I don't want to use the method form here, I want it in app_controller, and I want using session[:session_id]
  5.     #instead of rand and shit
  6.     name = "anonymous_#{rand}_#{Time.now}_#{rand}"
  7.     if User.find_by_username(name)
  8.       UserSession.create(User.find_by_username(name),true)
  9.     else
  10.       guest_role = User.create(:username => name, :password => name, :password_confirmation => name, :role => "guest", :email => "change@this.com")
  11.       UserSession.create(guest_role, true)
  12.     end
  13.     @current_user_session = UserSession.find
  14.     guest_role
  15.   end
  16.  
  17.   def require_login
  18.     login_as_trial_user unless current_user_session
  19.   end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top