diaspora/app/controllers/api/v1/tokens_controller.rb
Lukas Matt 24e1732256 Implement token authentication
* create a new token on a new session
* delete the current token on session exit
2014-11-13 11:27:56 +01:00

16 lines
423 B
Ruby

class Api::V1::TokensController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :authenticate_user!
respond_to :json
def create
current_user.ensure_authentication_token!
render :status => 200, :json => { :token => current_user.authentication_token }
end
def destroy
current_user.reset_authentication_token!
render :json => true, :status => 200
end
end