mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-08 18:35:46 +08:00
Adds a Discourse ID authenticator. Not available for use in production just yet, but soon communities will be able to use this service to let users authenticate using a central Discourse ID account. Includes a support for a `/revoke` action, allowing users to log out of multiple client instances from a central auth service. Internal ticket: t/155397 --------- Co-authored-by: Loïc Guitaut <loic@discourse.org>
21 lines
792 B
Ruby
21 lines
792 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Users::DiscourseIdController < ApplicationController
|
|
skip_before_action :verify_authenticity_token, only: [:revoke]
|
|
|
|
def revoke
|
|
RateLimiter.new(nil, "discourse_id_revoke_#{params[:identifier]}", 5, 1.minute).performed!
|
|
|
|
DiscourseId::Revoke.call(service_params) do |result|
|
|
on_success { render json: { success: true } }
|
|
on_failed_contract do |contract|
|
|
logger.warn(result.inspect_steps) if SiteSetting.discourse_id_verbose_logging
|
|
render json: { error: contract.errors.full_messages.join(", ") }, status: 400
|
|
end
|
|
on_failure do
|
|
logger.warn(result.inspect_steps) if SiteSetting.discourse_id_verbose_logging
|
|
render json: { error: "Invalid request" }, status: 400
|
|
end
|
|
end
|
|
end
|
|
end
|