|
c07a5659
»
|
seven1m |
2008-08-05 |
Added API key support and h... |
1 |
class Administration::ApiKeysController < ApplicationController |
| |
2 |
before_filter :only_admins |
| |
3 |
|
| |
4 |
def show |
| |
5 |
@key = @logged_in.api_key |
| |
6 |
end |
| |
7 |
|
| |
8 |
def create |
| |
9 |
@logged_in.generate_api_key |
| |
10 |
@logged_in.save! |
| |
11 |
redirect_to administration_api_key_path |
| |
12 |
end |
| |
13 |
|
| |
14 |
def destroy |
| |
15 |
@logged_in.api_key = nil |
| |
16 |
@logged_in.save! |
| |
17 |
redirect_to administration_api_key_path |
| |
18 |
end |
| |
19 |
|
| |
20 |
private |
| |
21 |
|
| |
22 |
def only_admins |
| |
23 |
unless @logged_in.super_admin? |
| |
24 |
render :text => 'You must be a super administrator to use the API.', :layout => true, :status => 401 |
| |
25 |
return false |
| |
26 |
end |
| |
27 |
end |
| |
28 |
|
| |
29 |
end |