When Local Login is disabled without an authenticator UsersController.create returns 500 internal error

sso
api

(Keith Newton) #1

In users_controller.rb line 303:

if !authentication.has_authenticator? && !SiteSetting.enable_local_logins
  return render nothing: true, status: 500
end

You can see that a 500 internal error is returned without any other sort of error message or indication of what the problem could be. While creating a user with the Discourse API I lost a bunch of time today thinking that something was wrong with my server instance. The logs had no information around the error and it was a bit perplexing to figure out what was going on. It doesn’t look like I can submit issues on the GitHub page so please consider this a request to add better logging or return a json failure similar to the code right below it:

render json: {
    success: false,
    message: I18n.t(
      'login.errors',
      errors: user.errors.full_messages.join("\n")
    ),
    errors: user.errors.to_hash,
    values: user.attributes.slice('name', 'username', 'email')
}

(Jeff Atwood) #2

I am always a fan of better error messages!