seven1m / onebody

OneBody is free, open-source, web-based social networking and online directory software for churches.

This URL has Read+Write access

onebody / app / controllers / administration / api_keys_controller.rb
100644 30 lines (23 sloc) 0.603 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class Administration::ApiKeysController < ApplicationController
  before_filter :only_admins
  
  def show
    @key = @logged_in.api_key
  end
  
  def create
    @logged_in.generate_api_key
    @logged_in.save!
    redirect_to administration_api_key_path
  end
 
  def destroy
    @logged_in.api_key = nil
    @logged_in.save!
    redirect_to administration_api_key_path
  end
  
  private
  
    def only_admins
      unless @logged_in.super_admin?
        render :text => 'You must be a super administrator to use the API.', :layout => true, :status => 401
        return false
      end
    end
 
end