asciinema.org/app/controllers/user_tokens_controller.rb

31 lines
641 B
Ruby
Raw Normal View History

2012-03-04 19:30:26 +00:00
class UserTokensController < ApplicationController
before_filter :ensure_authenticated!
2012-03-04 19:30:26 +00:00
def create
claimed_num = user_token_creator.create(current_user, params[:user_token])
2012-03-04 19:30:26 +00:00
if claimed_num
redirect_to_profile(claimed_num)
else
render :error
end
end
2012-03-04 19:30:26 +00:00
private
2012-03-04 19:30:26 +00:00
def redirect_to_profile(claimed_num)
if claimed_num > 0
notice = "Claimed #{claimed_num} asciicasts, yay!"
2012-03-04 19:30:26 +00:00
else
notice = "Authenticated successfully, yippie!"
2012-03-04 19:30:26 +00:00
end
redirect_to profile_path(current_user), :notice => notice
end
def user_token_creator
@user_token_creator ||= UserTokenCreator.new
2012-03-04 19:30:26 +00:00
end
2012-03-04 19:30:26 +00:00
end