diff --git a/res/css/views/auth/_LoginWithQR.pcss b/res/css/views/auth/_LoginWithQR.pcss index c246388869..9d4744a389 100644 --- a/res/css/views/auth/_LoginWithQR.pcss +++ b/res/css/views/auth/_LoginWithQR.pcss @@ -11,6 +11,13 @@ Please see LICENSE files in the repository root for full details. margin-bottom: $spacing-16; } +.mx_LoginWithQRSection { + .mx_AccessibleButton_kind_primary + p { + color: var(--cpd-color-text-secondary); + margin-top: var(--cpd-space-2x); + } +} + .mx_LoginWithQRSection .mx_AccessibleButton svg { margin-right: $spacing-12; } @@ -135,9 +142,16 @@ Please see LICENSE files in the repository root for full details. padding: var(--cpd-space-3x); gap: 10px; - background-color: var(--cpd-color-bg-success-subtle); + background-color: var(--cpd-color-bg-subtle-secondary); svg { - color: var(--cpd-color-icon-success-primary); + color: var(--cpd-color-icon-secondary); + } + + &.mx_LoginWithQR_icon--success { + background-color: var(--cpd-color-bg-success-subtle); + svg { + color: var(--cpd-color-icon-success-primary); + } } &.mx_LoginWithQR_icon--critical { diff --git a/src/components/structures/UserMenu.tsx b/src/components/structures/UserMenu.tsx index ac6a8c8e0b..4bdb6e227b 100644 --- a/src/components/structures/UserMenu.tsx +++ b/src/components/structures/UserMenu.tsx @@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details. */ import React, { createRef, ReactNode } from "react"; -import { discoverAndValidateOIDCIssuerWellKnown, Room } from "matrix-js-sdk/src/matrix"; +import { Room } from "matrix-js-sdk/src/matrix"; import { MatrixClientPeg } from "../../MatrixClientPeg"; import defaultDispatcher from "../../dispatcher/dispatcher"; @@ -44,8 +44,6 @@ import { Icon as LiveIcon } from "../../../res/img/compound/live-8px.svg"; import { VoiceBroadcastRecording, VoiceBroadcastRecordingsStoreEvent } from "../../voice-broadcast"; import { SDKContext } from "../../contexts/SDKContext"; import { shouldShowFeedback } from "../../utils/Feedback"; -import { shouldShowQr } from "../views/settings/devices/LoginWithQRSection"; -import { Features } from "../../settings/Settings"; interface IProps { isPanelCollapsed: boolean; @@ -60,8 +58,6 @@ interface IState { isHighContrast: boolean; selectedSpace?: Room | null; showLiveAvatarAddon: boolean; - showQrLogin: boolean; - supportsQrLogin: boolean; } const toRightOf = (rect: PartialDOMRect): MenuProps => { @@ -98,8 +94,6 @@ export default class UserMenu extends React.Component { isHighContrast: this.isUserOnHighContrastTheme(), selectedSpace: SpaceStore.instance.activeSpaceRoom, showLiveAvatarAddon: this.context.voiceBroadcastRecordingsStore.hasCurrent(), - showQrLogin: false, - supportsQrLogin: false, }; OwnProfileStore.instance.on(UPDATE_EVENT, this.onProfileUpdate); @@ -123,7 +117,6 @@ export default class UserMenu extends React.Component { ); this.dispatcherRef = defaultDispatcher.register(this.onAction); this.themeWatcherRef = SettingsStore.watchSetting("theme", null, this.onThemeChanged); - this.checkQrLoginSupport(); } public componentWillUnmount(): void { @@ -138,29 +131,6 @@ export default class UserMenu extends React.Component { ); } - private checkQrLoginSupport = async (): Promise => { - if (!this.context.client || !SettingsStore.getValue(Features.OidcNativeFlow)) return; - - const { issuer } = await this.context.client.getAuthIssuer().catch(() => ({ issuer: undefined })); - if (issuer) { - const [oidcClientConfig, versions, wellKnown, isCrossSigningReady] = await Promise.all([ - discoverAndValidateOIDCIssuerWellKnown(issuer), - this.context.client.getVersions(), - this.context.client.waitForClientWellKnown(), - this.context.client.getCrypto()?.isCrossSigningReady(), - ]); - - const supportsQrLogin = shouldShowQr( - this.context.client, - !!isCrossSigningReady, - oidcClientConfig, - versions, - wellKnown, - ); - this.setState({ supportsQrLogin, showQrLogin: true }); - } - }; - private isUserOnDarkTheme(): boolean { if (SettingsStore.getValue("use_system_theme")) { return window.matchMedia("(prefers-color-scheme: dark)").matches; @@ -363,28 +333,13 @@ export default class UserMenu extends React.Component { ); } - let linkNewDeviceButton: JSX.Element | undefined; - if (this.state.showQrLogin) { - const extraProps: Omit< - React.ComponentProps, - "iconClassname" | "label" | "onClick" - > = {}; - if (!this.state.supportsQrLogin) { - extraProps.disabled = true; - extraProps.title = _t("user_menu|link_new_device_not_supported"); - extraProps.caption = _t("user_menu|link_new_device_not_supported_caption"); - extraProps.placement = "right"; - } - - linkNewDeviceButton = ( - this.onSettingsOpen(e, UserTab.SessionManager, { showMsc4108QrCode: true })} - /> - ); - } + const linkNewDeviceButton = ( + this.onSettingsOpen(e, UserTab.SessionManager, { showMsc4108QrCode: true })} + /> + ); let primaryOptionList = ( diff --git a/src/components/views/auth/LoginWithQRFlow.tsx b/src/components/views/auth/LoginWithQRFlow.tsx index 72511f2ccb..645613dafe 100644 --- a/src/components/views/auth/LoginWithQRFlow.tsx +++ b/src/components/views/auth/LoginWithQRFlow.tsx @@ -17,6 +17,7 @@ import CheckCircleSolidIcon from "@vector-im/compound-design-tokens/assets/web/i import ErrorIcon from "@vector-im/compound-design-tokens/assets/web/icons/error"; import { Heading, MFAInput, Text } from "@vector-im/compound-web"; import classNames from "classnames"; +import { QrCodeIcon } from "@vector-im/compound-design-tokens/assets/web/icons"; import { _t } from "../../../languageHandler"; import AccessibleButton from "../elements/AccessibleButton"; @@ -94,7 +95,10 @@ export default class LoginWithQRFlow extends React.Component
- {success ? : } +
{title} diff --git a/src/components/views/settings/devices/LoginWithQRSection.tsx b/src/components/views/settings/devices/LoginWithQRSection.tsx index f776d69765..c5efb35efc 100644 --- a/src/components/views/settings/devices/LoginWithQRSection.tsx +++ b/src/components/views/settings/devices/LoginWithQRSection.tsx @@ -18,12 +18,11 @@ import { DEVICE_CODE_SCOPE, } from "matrix-js-sdk/src/matrix"; import QrCodeIcon from "@vector-im/compound-design-tokens/assets/web/icons/qr-code"; +import { Text } from "@vector-im/compound-web"; import { _t } from "../../../../languageHandler"; import AccessibleButton from "../../elements/AccessibleButton"; import SettingsSubsection from "../shared/SettingsSubsection"; -import SettingsStore from "../../../../settings/SettingsStore"; -import { Features } from "../../../../settings/Settings"; import { useMatrixClientContext } from "../../../../contexts/MatrixClientContext"; interface IProps { @@ -64,9 +63,8 @@ export function shouldShowQr( oidcClientConfig?.metadata?.grant_types_supported.includes(DEVICE_CODE_SCOPE); return ( - deviceAuthorizationGrantSupported && + !!deviceAuthorizationGrantSupported && msc4108Supported && - SettingsStore.getValue(Features.OidcNativeFlow) && !!cli.getCrypto()?.exportSecretsBundle && isCrossSigningReady ); @@ -85,19 +83,15 @@ const LoginWithQRSection: React.FC = ({ ? shouldShowQr(cli, !!isCrossSigningReady, oidcClientConfig, versions, wellKnown) : shouldShowQrLegacy(versions, wellKnown, capabilities); - // don't show anything if no method is available - if (!offerShowQr) { - return null; - } - return (

{_t("settings|sessions|sign_in_with_qr_description")}

- + {_t("settings|sessions|sign_in_with_qr_button")} + {!offerShowQr && {_t("settings|sessions|sign_in_with_qr_unsupported")}}
); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 74265c1939..5c563bb78f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -283,6 +283,8 @@ "security_code_prompt": "If asked, enter the code below on your other device.", "select_qr_code": "Select \"%(scanQRCode)s\"", "sign_in_new_device": "Sign in new device", + "unsupported_explainer": "Your account provider doesn't support signing into a new device with a QR code.", + "unsupported_heading": "QR code not supported", "waiting_for_device": "Waiting for device to sign in" }, "register_action": "Create Account", @@ -2855,6 +2857,7 @@ "show_details": "Show details", "sign_in_with_qr": "Link new device", "sign_in_with_qr_button": "Show QR code", + "sign_in_with_qr_unsupported": "Not supported by your account provider", "sign_in_with_qr_description": "Use a QR code to sign in to another device and set up secure messaging.", "sign_out": "Sign out of this session", "sign_out_all_other_sessions": "Sign out of all other sessions (%(otherSessionsCount)s)", @@ -3832,8 +3835,6 @@ }, "user_menu": { "link_new_device": "Link new device", - "link_new_device_not_supported": "Not supported", - "link_new_device_not_supported_caption": "You need to sign in manually", "settings": "All settings", "switch_theme_dark": "Switch to dark mode", "switch_theme_light": "Switch to light mode"