Class: CortexReaver::UserController
- Inherits:
-
Controller
- Object
- Ramaze::Controller
- Controller
- CortexReaver::UserController
- Defined in:
- lib/cortex_reaver/controller/user.rb
Constant Summary collapse
- MODEL =
User
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
44 45 46 47 48 |
# File 'lib/cortex_reaver/controller/user.rb', line 44 def index @models = @users = User.select(:name, :id, :login) workflow "New User", rs(:new), :new, :user render_view :list end |
#login ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/cortex_reaver/controller/user.rb', line 50 def login @title = "Login" if request.post? if user = do_login(request[:login], request[:password]) # Successful login flash[:notice] = "Welcome, #{user.name}." if uri = session.delete(:target_uri) || request[:target_uri] # Send the user to their original destination. redirect uri else # Try the main page. redirect MainController.r end else # Nope, no login. flash[:error] = "Wrong username or password." redirect rs(:login) end end end |
#logout ⇒ Object
73 74 75 76 77 78 |
# File 'lib/cortex_reaver/controller/user.rb', line 73 def logout if user = do_logout flash[:notice] = "Goodbye, #{user.name}." end redirect '/' end |