Skip to content

Commit

Permalink
Display help prompt to enter a username when signing up from a provod…
Browse files Browse the repository at this point in the history
…er that does not provide username/nickname
  • Loading branch information
imorland committed Oct 13, 2021
1 parent 6ee0d7c commit b4883a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions js/src/forum/index.js
Expand Up @@ -5,6 +5,7 @@ import LogInButtons from 'flarum/forum/components/LogInButtons';
import LogInButton from 'flarum/forum/components/LogInButton';
import extractText from 'flarum/common/utils/extractText';
import Tooltip from 'flarum/common/components/Tooltip';
import SignUpModal from 'flarum/forum/components/SignUpModal';

app.initializers.add('fof/oauth', () => {
const onlyIcons = !!Number(app.data['fof-oauth.only_icons']);
Expand Down Expand Up @@ -43,4 +44,19 @@ app.initializers.add('fof/oauth', () => {
vdom.attrs.className += ' FoFLogInButtons--icons';
});
}

extend(SignUpModal.prototype, 'fields', function (items) {
// If a suggested username was not provided by the OAuth service, display some help text to the user.
if (!!this.attrs.token && !!!this.attrs.username) {
items.add(
'username-help',
<div>
<p>{app.translator.trans('fof-oauth.forum.signup.username_help')}</p>
</div>,
35
);
}

return items;
});
});
3 changes: 3 additions & 0 deletions resources/locale/en.yml
Expand Up @@ -77,6 +77,9 @@ fof-oauth:
linkedin: '=> fof-oauth.lib.providers.linkedin'
twitter: '=> fof-oauth.lib.providers.twitter'

signup:
username_help: Please choose a username to be known by here

error:
bad_verification_code: Invalid or expired verification token. Please try again.
invalid_state: Invalid state. Please try again.
Expand Down

0 comments on commit b4883a8

Please sign in to comment.