Compare commits

...
This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.

2 Commits

Author SHA1 Message Date
Leonardo Mosquera
fed6115f68
UX: improve error message when no trust level to login from DiscourseHub
DiscourseHub requires generating API keys to login, which is affected by
the min_trust_level_for_user_api_key site setting.

If it is increased over the default of 0, then new users with 0 trust
level will not be able to login with the app, and in that case we would
be showing them a technical error message involving API keys, which
might be bad UX for newcomers to Discourse.

This commit differentiates exactly that case, and serves a less
technical error message.
2021-10-22 17:48:56 -03:00
Leonardo Mosquera
3e46ed0a2e
UX: clarify that min_trust_level_for_user_api_key affects DiscourseHub login
Expand this SiteSetting's description to clarify that DiscourseHub users
will not be able to log in unless they meet the trust level, since it
requires generating user API keys.

This way, site admins won't inadvertently lock new users out from the apps.
2021-10-22 16:01:42 -03:00
3 changed files with 12 additions and 2 deletions

View File

@ -33,6 +33,7 @@ class UserApiKeysController < ApplicationController
unless meets_tl?
@no_trust_level = true
@is_discourse_hub_app = true if is_discourse_hub_app?
return
end
@ -197,6 +198,10 @@ class UserApiKeysController < ApplicationController
current_user.staff? || current_user.trust_level >= SiteSetting.min_trust_level_for_user_api_key
end
def is_discourse_hub_app?
params[:discourse_app] == '1'
end
def one_time_password(public_key, username)
raise Discourse::InvalidAccess unless UserApiKey.allowed_scopes.superset?(Set.new(["one_time_password"]))

View File

@ -1,6 +1,10 @@
<h1><%= t "user_api_key.title" %></h1>
<div class='authorize-api-key'>
<% if @no_trust_level %>
<% if @no_trust_level && @is_discourse_hub_app %>
<h3>
<%= t("user_api_key.no_trust_level_discourse_hub") %>
</h3>
<% elsif @no_trust_level && ! @is_discourse_hub_app %>
<h3>
<%= t("user_api_key.no_trust_level") %>
</h3>

View File

@ -1078,6 +1078,7 @@ en:
logging_in_as: Logging in as %{username}
confirm_button: Finish Login
no_trust_level: "Sorry, you do not have the required trust level to access the user API"
no_trust_level_discourse_hub: "Sorry, you do not have the required user trust level to log in with DiscourseHub. Please contact site administrators and mention this error."
generic_error: "Sorry, we are unable to issue user API keys, this feature may be disabled by the site admin"
scopes:
message_bus: "Live updates"
@ -2269,7 +2270,7 @@ en:
allow_user_api_keys: "Allow generation of user API keys"
allow_user_api_key_scopes: "List of scopes allowed for user API keys"
min_trust_level_for_user_api_key: "Trust level required for generation of user API keys"
min_trust_level_for_user_api_key: "Trust level required for generation of user API keys. Note that login with DiscourseHub, our mobile app, requires generating user API keys."
allowed_user_api_auth_redirects: "Allowed URL for authentication redirect for user API keys. Wildcard symbol * can be used to match any part of it (e.g. www.example.com/*)."
allowed_user_api_push_urls: "Allowed URLs for server push to user API"
expire_user_api_keys_days: "Number of days before a user API key automatically expires (0 for never)"