Module: Koinz::Controllers::InternalHelpers
- Defined in:
- lib/koinz/controllers/internal_helpers.rb
Instance Method Summary collapse
- #get_session_access_token ⇒ Object
-
#is_admin ⇒ Object
before_filter: Called when you want to redirect if not admin.
-
#is_admin? ⇒ Boolean
Only checks and returns admin status.
-
#login_required ⇒ Object
before_filter: called explicity if login_required handles auth_token and two-legged token too.
Instance Method Details
#get_session_access_token ⇒ Object
37 38 39 |
# File 'lib/koinz/controllers/internal_helpers.rb', line 37 def get_session_access_token session ? session[:user_id]['credentials']['token'] : nil end |
#is_admin ⇒ Object
before_filter: Called when you want to redirect if not admin
27 28 29 30 31 32 33 34 35 |
# File 'lib/koinz/controllers/internal_helpers.rb', line 27 def is_admin # We could later save the admin flag in the User Session if is_admin? return true else flash[:notice] = "You don't have sufficient privilege." redirect_to no_privilage_path end end |
#is_admin? ⇒ Boolean
Only checks and returns admin status
22 23 24 |
# File 'lib/koinz/controllers/internal_helpers.rb', line 22 def is_admin? session[:user_id] && session[:user_id]["extra"]["admin"] == true end |
#login_required ⇒ Object
before_filter: called explicity if login_required handles auth_token and two-legged token too
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/koinz/controllers/internal_helpers.rb', line 7 def login_required if !current_user respond_to do |format| format.html { session[:user_id] = nil redirect_to login_required_path } format.json { render :json => { 'error' => 'Access Denied' }.to_json } end end end |