mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 18:16:06 +08:00
FEATURE: Allow linking an existing account from invite acceptance (#13998)
The invite acceptance page is an alternative signup flow, so it makes sense to include the new 'link' functionality there as well. Followup to 7dc8f8b794cbb36b14737710ccfe417d1c074d12
This commit is contained in:
@ -212,6 +212,17 @@ export default Controller.extend(
|
||||
@discourseComputed
|
||||
ssoPath: () => getUrl("/session/sso"),
|
||||
|
||||
@discourseComputed("authOptions.associate_url", "authOptions.auth_provider")
|
||||
associateHtml(url, provider) {
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
return I18n.t("create_account.associate", {
|
||||
associate_link: url,
|
||||
provider: I18n.t(`login.${provider}.name`),
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
submit() {
|
||||
const userFields = this.userFields;
|
||||
|
@ -20,6 +20,12 @@
|
||||
<p>{{i18n "invites.invited_by"}}</p>
|
||||
<p>{{user-info user=invitedBy}}</p>
|
||||
|
||||
{{#if associateHtml}}
|
||||
<p class="create-account-associate-link">
|
||||
{{html-safe associateHtml}}
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
{{#unless isInviteLink}}
|
||||
<p class="email-message">
|
||||
{{html-safe yourEmailMessage}}
|
||||
|
@ -451,3 +451,30 @@ acceptance(
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
acceptance(
|
||||
"Invite link with authentication data, and associate link",
|
||||
function (needs) {
|
||||
needs.settings({ enable_local_logins: false });
|
||||
|
||||
setAuthenticationData(needs.hooks, {
|
||||
auth_provider: "facebook",
|
||||
email: "blah@example.com",
|
||||
email_valid: true,
|
||||
username: "foobar",
|
||||
name: "barfoo",
|
||||
associate_url: "/associate/abcde",
|
||||
});
|
||||
|
||||
test("shows the associate link", async function (assert) {
|
||||
preloadInvite({ link: true });
|
||||
|
||||
await visit("/invites/myvalidinvitetoken");
|
||||
|
||||
assert.ok(
|
||||
exists(".create-account-associate-link"),
|
||||
"shows the associate account link"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Reference in New Issue
Block a user