2014-02-09 13:44:09 +00:00
|
|
|
class ApiTokensController < ApplicationController
|
2014-02-12 16:41:06 +00:00
|
|
|
|
2012-03-06 18:51:21 +00:00
|
|
|
before_filter :ensure_authenticated!
|
2012-03-04 19:30:26 +00:00
|
|
|
|
|
|
|
def create
|
2014-02-12 16:41:06 +00:00
|
|
|
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."
|
2013-09-25 16:01:54 +00:00
|
|
|
|
2014-02-12 16:41:06 +00:00
|
|
|
rescue ActiveRecord::RecordInvalid, ApiToken::ApiTokenTakenError
|
|
|
|
render :error
|
2012-03-04 19:30:26 +00:00
|
|
|
end
|
2013-09-25 16:01:54 +00:00
|
|
|
|
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
|