scube-server/app/controllers/application_controller.rb
Thibault Jouan 7bf4d4c5f9 Add authentication and User model
* Add User model
* Add SessionsController
* Add password authentication on User
* Request authentication for all actions except sign in
* Add some helpers for ApplicationController
* Update features to work with mandatory authentication
2011-08-06 23:04:36 +00:00

20 lines
369 B
Ruby

class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate!
def current_user=(user)
session[:user_id] = user.id
end
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
protected
def authenticate!
redirect_to new_session_path if current_user.nil?
end
end