Files
libr-2/app/controllers/api/v1/sessions_controller.rb
T
2015-08-02 13:33:56 +08:00

18 lines
436 B
Ruby

class Api::V1::SessionsController < Devise::SessionsController
skip_before_action :verify_authenticity_token
def create
warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure")
render json: user_json
end
def destroy
sign_out(resource_name)
end
def failure
render :json => {:success => false, :errors => '用户名或者密码错误,请重试'}, status: :forbidden
end
end