asciinema.org/app/controllers/api_tokens_controller.rb

22 lines
527 B
Ruby
Raw Normal View History

2014-02-09 13:44:09 +00:00
class ApiTokensController < ApplicationController
before_filter :ensure_authenticated!
2012-03-04 19:30:26 +00:00
def create
current_user.assign_api_token(params[:api_token])
redirect_to profile_path(current_user),
2015-04-02 09:45:39 +00:00
notice: "Successfully registered your recorder token."
rescue ActiveRecord::RecordInvalid, ApiToken::ApiTokenTakenError
render :error
2012-03-04 19:30:26 +00:00
end
2015-04-02 09:45:39 +00:00
def destroy
api_token = ApiToken.find(params[:id])
authorize api_token
api_token.revoke!
redirect_to edit_user_path, notice: "Token revoked."
end
2012-03-04 19:30:26 +00:00
end