Created
September 2, 2012 01:08
-
-
Save JFickel/3593057 to your computer and use it in GitHub Desktop.
app controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
before_filter :current_user | |
require 'open-uri' | |
require 'json' | |
require 'nokogiri' | |
require 'ostruct' | |
def logged_in? | |
session[:user_id].present? | |
end | |
def current_user | |
@current_user ||= User.find_by_id(session[:user_id]) | |
end | |
def redirect_if_not_team_admin(team, current_user) | |
team_admin_check = TeamRole.where('team_id = ? AND user_id = ? AND admin = ?', team.id, current_user.id, true) | |
if current_user.nil? || team_admin_check.nil? | |
flash[:error] = "Not authorized" | |
redirect_to root_url | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment