You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
635 B
Ruby
31 lines
635 B
Ruby
11 years ago
|
class ApiTokensController < ApplicationController
|
||
13 years ago
|
before_filter :ensure_authenticated!
|
||
13 years ago
|
|
||
|
def create
|
||
11 years ago
|
claimed_num = api_token_creator.create(current_user, params[:api_token])
|
||
13 years ago
|
|
||
11 years ago
|
if claimed_num
|
||
|
redirect_to_profile(claimed_num)
|
||
|
else
|
||
|
render :error
|
||
|
end
|
||
|
end
|
||
13 years ago
|
|
||
11 years ago
|
private
|
||
13 years ago
|
|
||
11 years ago
|
def redirect_to_profile(claimed_num)
|
||
|
if claimed_num > 0
|
||
|
notice = "Claimed #{claimed_num} asciicasts, yay!"
|
||
13 years ago
|
else
|
||
11 years ago
|
notice = "Authenticated successfully, yippie!"
|
||
13 years ago
|
end
|
||
11 years ago
|
|
||
|
redirect_to profile_path(current_user), :notice => notice
|
||
|
end
|
||
|
|
||
11 years ago
|
def api_token_creator
|
||
|
@api_token_creator ||= ApiTokenCreator.new
|
||
13 years ago
|
end
|
||
11 years ago
|
|
||
13 years ago
|
end
|