asciinema.org/app/controllers/user_tokens_controller.rb

22 lines
519 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
ut = current_user.add_user_token(params[:user_token])
if ut.valid?
claimed_num = Asciicast.assign_user(ut.token, current_user)
if claimed_num > 0
notice = "Claimed #{claimed_num} asciicasts, yay!"
else
notice = "Authenticated successfully, yippie!"
end
redirect_to profile_path(current_user), :notice => notice
2012-03-04 19:30:26 +00:00
else
render :error
end
end
end