2012-03-04 19:30:26 +00:00
|
|
|
class UserTokensController < ApplicationController
|
2012-03-06 18:51:21 +00:00
|
|
|
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
|
|
|
|
|
2012-03-06 18:44:05 +00:00
|
|
|
redirect_to profile_path(current_user), :notice => notice
|
2012-03-04 19:30:26 +00:00
|
|
|
else
|
|
|
|
render :error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|