daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest May 22nd, 2018 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Auth < Merb::Controller
  2.   before :get_user
  3.  
  4.   def index
  5.     render :index
  6.   end
  7.  
  8.   def test
  9.     render 'Test page'
  10.   end
  11.  
  12.   def login
  13.     user = User.first(:login => params['login'])
  14.     if user
  15.       if user.password == params['password']
  16.         session['user_id'] = user.id
  17.         redirect url(:controller => :dashboard)
  18.         #render "FAIL"
  19.       else
  20.         @error = "The password was incorrect"
  21.         render :index
  22.       end
  23.     else
  24.       @error = "There is no user with that name"
  25.       render :index
  26.     end
  27.   end
  28.  
  29.   def logout
  30.     render "Logged out"
  31.   end
  32. end
  33.  
  34. class Dashboard < Merb::Controller
  35.   before :get_user
  36.  
  37.   def index
  38.     render :index
  39.   end
  40. end
  41.  
  42. class Application < Merb::Controller
  43.   def get_user
  44.     @user = User[session['user_id']] if session['user_id']
  45.   end
  46. 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