Skip to content

Modular logistics and supply chain operating system (LSOS)

feat(oauth): automatic linking toggle, linked notice, and room below the form

Ronald A. Richardsonbb81c4902e0d
diff --git a/console/app/components/configure/oauth.hbs b/console/app/components/configure/oauth.hbs
index 7b4e6bde..033fe3e2 100644
--- a/console/app/components/configure/oauth.hbs
+++ b/console/app/components/configure/oauth.hbs
@@ -19,6 +19,14 @@
@helpText="When off, only people who already have an account and have linked the provider can sign in with it."
/>
</InputGroup>
+ <InputGroup>
+ <Toggle
+ @isToggled={{this.autoLink}}
+ @onToggle={{fn (mut this.autoLink)}}
+ @label="Link existing accounts automatically"
+ @helpText="When someone signs in with a provider for the first time and the provider has verified their email, link it to the console account with that confirmed email instead of asking them to link it themselves. Only admin and user accounts, never customers, contacts or drivers. Two-factor still applies, and the account holder is emailed."
+ />
+ </InputGroup>
</ContentPanel>
{{#each this.providers key="id" as |provider|}}
@@ -85,6 +93,8 @@
</ContentPanel>
{{/each}}
+<Spacer @height="100px" />
+
<EmberWormhole @to="next-view-section-subheader-actions">
<Button @type="primary" @size="sm" @icon="save" @text="Save Changes" @onClick={{perform this.save}} @disabled={{this.save.isRunning}} @isLoading={{this.save.isRunning}} />
</EmberWormhole>
\ No newline at end of file
diff --git a/console/app/components/configure/oauth.js b/console/app/components/configure/oauth.js
index 55f6824e..b3908fbe 100644
--- a/console/app/components/configure/oauth.js
+++ b/console/app/components/configure/oauth.js
@@ -20,6 +20,7 @@ export default class ConfigureOauthComponent extends Component {
@tracked enabled = true;
@tracked allowRegistration = true;
+ @tracked autoLink = true;
/**
* [{ id, label, icon, schema }]
@@ -161,6 +162,7 @@ export default class ConfigureOauthComponent extends Component {
this.redirectUris = payload.redirect_uris ?? {};
this.enabled = oauth.enabled !== false;
this.allowRegistration = oauth.allow_registration !== false;
+ this.autoLink = oauth.auto_link !== false;
const values = {};
const secretStatus = {};
@@ -221,6 +223,7 @@ export default class ConfigureOauthComponent extends Component {
return {
enabled: this.enabled,
allow_registration: this.allowRegistration,
+ auto_link: this.autoLink,
providers,
};
}
diff --git a/console/app/controllers/auth/oauth-callback.js b/console/app/controllers/auth/oauth-callback.js
index 19491265..0addeebd 100644
--- a/console/app/controllers/auth/oauth-callback.js
+++ b/console/app/controllers/auth/oauth-callback.js
@@ -121,6 +121,12 @@ export default class AuthOauthCallbackController extends Controller {
* @return {Promise<void>}
*/
async handle(response = {}, returnTo = null) {
+ // The provider was linked to an existing account on the way in, because its
+ // verified email matched. Said here, whichever way sign-in goes on from here.
+ if (response.linked) {
+ this.notifications.info(this.intl.t('auth.login.oauth.auto-linked', { provider: response.linked_label ?? response.linked }));
+ }
+
// 2FA is not waived for a provider sign-in — the server issues no token until
// the second factor is satisfied.
if (response.isEnabled === true && response.twoFaSession) {
diff --git a/console/tests/integration/components/configure/oauth-test.js b/console/tests/integration/components/configure/oauth-test.js
index 3d70b89d..ec3b9dc6 100644
--- a/console/tests/integration/components/configure/oauth-test.js
+++ b/console/tests/integration/components/configure/oauth-test.js
@@ -10,6 +10,7 @@ const CONFIG = {
oauth: {
enabled: true,
allow_registration: true,
+ auto_link: true,
providers: {
google: {
enabled: true,
@@ -152,6 +153,18 @@ module('Integration | Component | configure/oauth', function (hooks) {
assert.notOk('client_secret' in saved.providers.google, 'an untouched secret is not sent');
assert.notOk('private_key' in saved.providers.apple);
assert.strictEqual(saved.providers.google.enabled, true);
+ assert.true(saved.auto_link, 'automatic linking is sent with the global switches');
+ });
+
+ test('automatic linking can be switched off', async function (assert) {
+ const captured = captureComponent(this.owner, 'configure/oauth', ConfigureOauthComponent);
+ await render(hbs`<div id="next-view-section-subheader-actions"></div><Configure::Oauth />`);
+
+ assert.dom(this.element).containsText('Link existing accounts automatically');
+ captured.instance.autoLink = false;
+ await click('#next-view-section-subheader-actions button');
+
+ assert.false(this.posted.find((p) => p.path === 'settings/oauth-config').payload.auto_link);
});
test('saving sends a secret the admin typed', async function (assert) {
diff --git a/console/tests/unit/controllers/auth/oauth-callback-test.js b/console/tests/unit/controllers/auth/oauth-callback-test.js
index 1bb9a89a..c8fd7e6a 100644
--- a/console/tests/unit/controllers/auth/oauth-callback-test.js
+++ b/console/tests/unit/controllers/auth/oauth-callback-test.js
@@ -111,6 +111,33 @@ module('Unit | Controller | auth/oauth-callback', function (hooks) {
assert.deepEqual(this.manualTokens, [], 'no session is established yet');
});
+ test('it says when the provider was linked automatically on the way in', async function (assert) {
+ this.exchangeResult = () => Promise.resolve({ token: 'sanctum-token', type: 'user', linked: 'google', linked_label: 'Google' });
+ const calls = [];
+ Object.defineProperty(this.controller.intl, 't', { configurable: true, value: (key, options) => (calls.push([key, options]), key) });
+
+ await this.controller.start({ handoff: 'handoff-code' });
+
+ assert.deepEqual(this.notified.info, ['auth.login.oauth.auto-linked']);
+ assert.deepEqual(calls, [['auth.login.oauth.auto-linked', { provider: 'Google' }]]);
+ assert.deepEqual(this.manualTokens, ['sanctum-token']);
+ });
+
+ test('it says so before a two factor challenge too', async function (assert) {
+ this.exchangeResult = () => Promise.resolve({ isEnabled: true, twoFaSession: 'two-fa-token', linked: 'google', linked_label: 'Google' });
+
+ await this.controller.start({ handoff: 'handoff-code' });
+
+ assert.deepEqual(this.notified.info, ['auth.login.oauth.auto-linked']);
+ assert.deepEqual(this.transitions, [['auth.two-fa', { queryParams: { token: 'two-fa-token' } }]]);
+ });
+
+ test('an ordinary sign-in says nothing about linking', async function (assert) {
+ await this.controller.start({ handoff: 'handoff-code' });
+
+ assert.deepEqual(this.notified.info, []);
+ });
+
test('it hands a registration intent to the onboarding flow', async function (assert) {
this.exchangeResult = () =>
Promise.resolve({
diff --git a/console/translations/ar-ae.yaml b/console/translations/ar-ae.yaml
index 2ce38029..8373e7e2 100644
--- a/console/translations/ar-ae.yaml
+++ b/console/translations/ar-ae.yaml
@@ -581,6 +581,7 @@ auth:
unlink-title: 'إلغاء ربط {provider}؟'
unlink-body: 'لن تتمكن بعد الآن من تسجيل الدخول عبر {provider}. يمكنك ربطه مجددًا لاحقًا.'
linked: 'تم ربط المزوّد بحسابك.'
+ auto-linked: 'تم ربط {provider} بحسابك. يمكنك تسجيل الدخول به من الآن فصاعدًا.'
unlinked: 'تم إلغاء ربط {provider}.'
errors:
generic: 'تعذّر إكمال تسجيل الدخول. يرجى المحاولة مرة أخرى.'
diff --git a/console/translations/bg-bg.yaml b/console/translations/bg-bg.yaml
index 342566ea..3c0732ca 100644
--- a/console/translations/bg-bg.yaml
+++ b/console/translations/bg-bg.yaml
@@ -588,6 +588,7 @@ auth:
unlink-title: 'Да се прекъсне ли {provider}?'
unlink-body: 'Вече няма да можете да влизате чрез {provider}. Можете да го свържете отново по-късно.'
linked: 'Доставчикът е свързан с профила ви.'
+ auto-linked: '{provider} вече е свързан с профила ви. Отсега нататък можете да влизате с него.'
unlinked: '{provider} е прекъснат.'
errors:
generic: 'Влизането не можа да бъде завършено. Опитайте отново.'
diff --git a/console/translations/de-de.yaml b/console/translations/de-de.yaml
index a4919549..b5e933fb 100644
--- a/console/translations/de-de.yaml
+++ b/console/translations/de-de.yaml
@@ -617,6 +617,7 @@ auth:
unlink-title: '{provider} trennen?'
unlink-body: 'Sie können sich dann nicht mehr über {provider} anmelden. Sie können ihn später erneut verknüpfen.'
linked: 'Anbieter mit Ihrem Konto verknüpft.'
+ auto-linked: '{provider} ist jetzt mit Ihrem Konto verknüpft. Sie können sich ab sofort damit anmelden.'
unlinked: '{provider} getrennt.'
errors:
generic: 'Die Anmeldung konnte nicht abgeschlossen werden. Bitte versuchen Sie es erneut.'
diff --git a/console/translations/en-us.yaml b/console/translations/en-us.yaml
index 3e4e1102..e154ead7 100644
--- a/console/translations/en-us.yaml
+++ b/console/translations/en-us.yaml
@@ -628,6 +628,7 @@ auth:
unlink-title: 'Unlink {provider}?'
unlink-body: 'You will no longer be able to sign in with {provider}. You can link it again later.'
linked: 'Provider linked to your account.'
+ auto-linked: '{provider} is now linked to your account. You can sign in with it from now on.'
unlinked: '{provider} unlinked.'
errors:
generic: 'We could not complete that sign-in. Please try again.'
diff --git a/console/translations/es-es.yaml b/console/translations/es-es.yaml
index 91677a59..7940eb9c 100644
--- a/console/translations/es-es.yaml
+++ b/console/translations/es-es.yaml
@@ -590,6 +590,7 @@ auth:
unlink-title: '¿Desvincular {provider}?'
unlink-body: 'Ya no podrá iniciar sesión con {provider}. Puede volver a vincularlo más adelante.'
linked: 'Proveedor vinculado a su cuenta.'
+ auto-linked: '{provider} ya está vinculado a su cuenta. A partir de ahora puede iniciar sesión con él.'
unlinked: '{provider} desvinculado.'
errors:
generic: 'No se pudo completar el inicio de sesión. Inténtelo de nuevo.'
diff --git a/console/translations/es-mx.yaml b/console/translations/es-mx.yaml
index 9f589fa8..b1cf5227 100644
--- a/console/translations/es-mx.yaml
+++ b/console/translations/es-mx.yaml
@@ -620,6 +620,7 @@ auth:
unlink-title: '¿Desvincular {provider}?'
unlink-body: 'Ya no podrás iniciar sesión con {provider}. Puedes volver a vincularlo más adelante.'
linked: 'Proveedor vinculado a tu cuenta.'
+ auto-linked: '{provider} ya está vinculado a tu cuenta. A partir de ahora puedes iniciar sesión con él.'
unlinked: '{provider} desvinculado.'
errors:
generic: 'No se pudo completar el inicio de sesión. Inténtalo de nuevo.'
diff --git a/console/translations/fa-ir.yaml b/console/translations/fa-ir.yaml
index d6a76a05..9eef9168 100644
--- a/console/translations/fa-ir.yaml
+++ b/console/translations/fa-ir.yaml
@@ -572,6 +572,7 @@ auth:
unlink-title: 'اتصال {provider} قطع شود؟'
unlink-body: 'دیگر نمی‌توانید با {provider} وارد شوید. بعداً می‌توانید دوباره آن را متصل کنید.'
linked: 'ارائه‌دهنده به حساب شما متصل شد.'
+ auto-linked: '{provider} اکنون به حساب شما متصل است. از این پس می‌توانید با آن وارد شوید.'
unlinked: 'اتصال {provider} قطع شد.'
errors:
generic: 'ورود کامل نشد. لطفاً دوباره تلاش کنید.'
diff --git a/console/translations/fr-fr.yaml b/console/translations/fr-fr.yaml
index a0779eba..2defc40b 100644
--- a/console/translations/fr-fr.yaml
+++ b/console/translations/fr-fr.yaml
@@ -591,6 +591,7 @@ auth:
unlink-title: 'Dissocier {provider} ?'
unlink-body: 'Vous ne pourrez plus vous connecter avec {provider}. Vous pourrez l''associer à nouveau plus tard.'
linked: 'Fournisseur associé à votre compte.'
+ auto-linked: '{provider} est maintenant associé à votre compte. Vous pouvez désormais vous connecter avec.'
unlinked: '{provider} dissocié.'
errors:
generic: 'La connexion n''a pas pu être finalisée. Veuillez réessayer.'
diff --git a/console/translations/it-it.yaml b/console/translations/it-it.yaml
index 7b218306..1c75726d 100644
--- a/console/translations/it-it.yaml
+++ b/console/translations/it-it.yaml
@@ -626,6 +626,7 @@ auth:
unlink-title: 'Scollegare {provider}?'
unlink-body: 'Non potrai più accedere con {provider}. Potrai collegarlo di nuovo in seguito.'
linked: 'Provider collegato al tuo account.'
+ auto-linked: '{provider} è ora collegato al tuo account. D’ora in poi puoi accedere con esso.'
unlinked: '{provider} scollegato.'
errors:
generic: 'Non è stato possibile completare l''accesso. Riprova.'
diff --git a/console/translations/mn-mn.yaml b/console/translations/mn-mn.yaml
index a010ab74..7117cfd6 100644
--- a/console/translations/mn-mn.yaml
+++ b/console/translations/mn-mn.yaml
@@ -589,6 +589,7 @@ auth:
unlink-title: '{provider}-г салгах уу?'
unlink-body: 'Та цаашид {provider}-ээр нэвтрэх боломжгүй болно. Дараа нь дахин холбож болно.'
linked: 'Үйлчилгээ таны бүртгэлд холбогдлоо.'
+ auto-linked: '{provider} таны бүртгэлд холбогдлоо. Одооноос түүгээр нэвтэрч болно.'
unlinked: '{provider} салгагдлаа.'
errors:
generic: 'Нэвтрэлтийг гүйцэтгэж чадсангүй. Дахин оролдоно уу.'
diff --git a/console/translations/pt-br.yaml b/console/translations/pt-br.yaml
index 31160da7..a51941f5 100644
--- a/console/translations/pt-br.yaml
+++ b/console/translations/pt-br.yaml
@@ -586,6 +586,7 @@ auth:
unlink-title: 'Desconectar {provider}?'
unlink-body: 'Você não poderá mais entrar com {provider}. Você pode conectá-lo novamente depois.'
linked: 'Provedor conectado à sua conta.'
+ auto-linked: '{provider} agora está conectado à sua conta. A partir de agora você pode entrar com ele.'
unlinked: '{provider} desconectado.'
errors:
generic: 'Não foi possível concluir o login. Tente novamente.'
diff --git a/console/translations/ru-ru.yaml b/console/translations/ru-ru.yaml
index 7178b264..07d80035 100644
--- a/console/translations/ru-ru.yaml
+++ b/console/translations/ru-ru.yaml
@@ -587,6 +587,7 @@ auth:
unlink-title: 'Отвязать {provider}?'
unlink-body: 'Вы больше не сможете входить через {provider}. Позже его можно привязать снова.'
linked: 'Поставщик привязан к вашей учётной записи.'
+ auto-linked: '{provider} теперь привязан к вашей учётной записи. Теперь вы можете входить через него.'
unlinked: '{provider} отвязан.'
errors:
generic: 'Не удалось завершить вход. Попробуйте ещё раз.'
diff --git a/console/translations/uz-uz.yaml b/console/translations/uz-uz.yaml
index c763e32c..cb135327 100644
--- a/console/translations/uz-uz.yaml
+++ b/console/translations/uz-uz.yaml
@@ -601,6 +601,7 @@ auth:
unlink-title: '{provider} uzilsinmi?'
unlink-body: 'Endi {provider} orqali kira olmaysiz. Keyinroq uni qayta bog‘lashingiz mumkin.'
linked: 'Provayder hisobingizga bog‘landi.'
+ auto-linked: '{provider} endi hisobingizga bog‘landi. Bundan buyon u orqali kirishingiz mumkin.'
unlinked: '{provider} uzildi.'
errors:
generic: 'Kirishni yakunlab bo‘lmadi. Qaytadan urinib ko‘ring.'
diff --git a/console/translations/vi-vn.yaml b/console/translations/vi-vn.yaml
index da6c1b17..649f5fab 100644
--- a/console/translations/vi-vn.yaml
+++ b/console/translations/vi-vn.yaml
@@ -590,6 +590,7 @@ auth:
unlink-title: 'Hủy liên kết {provider}?'
unlink-body: 'Bạn sẽ không thể đăng nhập bằng {provider} nữa. Bạn có thể liên kết lại sau.'
linked: 'Đã liên kết nhà cung cấp với tài khoản của bạn.'
+ auto-linked: '{provider} đã được liên kết với tài khoản của bạn. Từ nay bạn có thể đăng nhập bằng nó.'
unlinked: 'Đã hủy liên kết {provider}.'
errors:
generic: 'Không thể hoàn tất đăng nhập. Vui lòng thử lại.'
diff --git a/console/translations/zh-cn.yaml b/console/translations/zh-cn.yaml
index b79381a0..db21d76c 100644
--- a/console/translations/zh-cn.yaml
+++ b/console/translations/zh-cn.yaml
@@ -565,6 +565,7 @@ auth:
unlink-title: '取消关联 {provider}?'
unlink-body: '您将无法再使用 {provider} 登录。之后可以重新关联。'
linked: '已将登录方式关联到您的账户。'
+ auto-linked: '{provider} 已关联到您的账户。今后您可以使用它登录。'
unlinked: '已取消关联 {provider}。'
errors:
generic: '无法完成登录,请重试。'