Have log_out method return json.

This commit helps improve the discourse_api experience so that we can
check the json response if it was a success or not. This commit also
checks that a 404 is sent instead of a 500 if a bad user_id is passed
in.
This commit is contained in:
Blake Erickson
2014-12-01 06:03:25 -07:00
parent a85a3da167
commit bdc92eec70
3 changed files with 32 additions and 4 deletions

View File

@ -66,10 +66,14 @@ class Admin::UsersController < Admin::AdminController
end
def log_out
@user.auth_token = nil
@user.save!
MessageBus.publish "/logout", @user.id, user_ids: [@user.id]
render nothing: true
if @user
@user.auth_token = nil
@user.save!
MessageBus.publish "/logout", @user.id, user_ids: [@user.id]
render json: success_json
else
render json: {error: I18n.t('admin_js.admin.users.id_not_found')}, status: 404
end
end
def refresh_browsers