Skip to content

Modular logistics and supply chain operating system (LSOS)

fix(oauth): lock the sign-up email only when the provider verified it

Ronald A. Richardsonc528087a9fdb
diff --git a/console/app/components/onboarding/form.js b/console/app/components/onboarding/form.js
index 38124474..1ae7e384 100644
--- a/console/app/components/onboarding/form.js
+++ b/console/app/components/onboarding/form.js
@@ -36,6 +36,7 @@ export default class OnboardingFormComponent extends Component {
this.oauthIntent = registration.intent;
this.name = registration.prefill?.name ?? null;
this.email = registration.prefill?.email ?? null;
+ this.emailVerifiedByProvider = registration.prefill?.email_verified === true;
}
}
@@ -72,11 +73,19 @@ export default class OnboardingFormComponent extends Component {
}
/**
- * The email came from the provider and the API will verify the intent against it,
- * so editing it here would only produce a mismatch the server rejects.
+ * Whether the provider vouched for the email it gave us.
+ *
+ * @var {Boolean}
+ */
+ @tracked emailVerifiedByProvider = false;
+
+ /**
+ * An email the provider verified is locked: it is what lets the account skip email
+ * verification. One the provider did not verify is only a suggestion, so the person
+ * can change it, and whatever they enter is verified by code as usual.
*/
get isEmailLocked() {
- return this.hasOauthIntent && !isBlank(this.email);
+ return this.hasOauthIntent && this.emailVerifiedByProvider && !isBlank(this.email);
}
get requiredFields() {
diff --git a/console/tests/integration/components/onboarding/form-test.js b/console/tests/integration/components/onboarding/form-test.js
index 48f44db1..43fb2530 100644
--- a/console/tests/integration/components/onboarding/form-test.js
+++ b/console/tests/integration/components/onboarding/form-test.js
@@ -260,6 +260,17 @@ module('Integration | Component | onboarding/form | onboard', function (hooks) {
assert.dom('input[type="email"]').isDisabled('the email is locked to the address the provider verified');
});
+ test('an email the provider did not verify stays editable', async function (assert) {
+ const oauth = this.owner.lookup('service:oauth');
+ oauth.setRegistration({ intent: 'rti_abc', prefill: { name: 'Ada Lovelace', email: '[email protected]', email_verified: false } });
+
+ await render(hbs`<Onboarding::Form />`);
+
+ // Only a suggestion: they may use another address, verified by code as usual.
+ assert.dom('input[type="email"]').hasValue('[email protected]');
+ assert.dom('input[type="email"]').isNotDisabled();
+ });
+
test('a provider signup can be submitted without a password', async function (assert) {
const oauth = this.owner.lookup('service:oauth');
oauth.setRegistration({ intent: 'rti_abc', prefill: { name: 'Ada Lovelace', email: '[email protected]' } });