Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements UIs for the "create account" and "sign in" flows in brave://settings #26741

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

szilardszaloki
Copy link
Collaborator

@szilardszaloki szilardszaloki commented Nov 25, 2024

Resolves brave/brave-browser#42508.

create_account_and_sign_in.mp4

Note: the tooltip and the corresponding regular expression-based password score implementation in the "create account" dialog have been removed in favor of getting the password strength from zxcvbn.

Known issues:

  • The recommended approach to a Lit element's HTML template is to have it defined in an .html.ts file that's directly checked in to the repository, that is, no .html files are going through the html_to_wrapper target in the WebUI build pipeline. As such, the HTML template definition is lacking the <!--_html_template_start_--> and <!--_html_template_end_--> tags, without which the C++ templatizer does not do any text replacements — hence those tags are currently added manually.

TODOs:

  • I suggest that we export noChange from third_party/lit/v3_0/lit.ts (which has been recently removed in Chromium due to deleting their only reference to it) and use it instead of the workaround that addresses a visual artifact in brave_account_create_dialog.html.ts.

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@szilardszaloki szilardszaloki requested review from a team and bridiver as code owners November 25, 2024 22:56
@github-actions github-actions bot added CI/storybook-url Deploy storybook and provide a unique URL for each build puLL-Merge labels Nov 25, 2024
Copy link
Contributor

The security team is monitoring all repositories for certain keywords. This PR includes the word(s) "password" and so security team members have been added as reviewers to take a look.

No need to request a full security review at this stage, the security team will take a look shortly and either clear the label or request more information/changes.

Notifications have already been sent, but if this is blocking your merge feel free to reach out directly to the security team on Slack so that we can expedite this check.

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

Copy link
Contributor

@fallaciousreasoning fallaciousreasoning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey this looks great - I had a dig into _html_template_start_ - man, this is why we can't have nice things 😆

It's such an ugly way of solving it, it makes me sad 😆 Thanks upstream.

My only real comment is that we should use a mojo interface instead of a handler

this.isCheckboxChecked = detail.checked
}

// TODO(sszaloki): we should consider exporting `noChange`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of interest, why would we need noChange here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, when there's a matching password in the password confirmation field, we show the checkmark and the text Passwords match. Now, if the user presses Cmd + Backspace on the text in the password confirmation field, we should just hide the dropdown and should not recalculate which icon or text to show — since the password confirmation field became empty, and there's nothing in there we should try to match against the field above. That's an edge-case here, but if we don't do anything, there's a visual artifact: the icon changes to the red triangle, while the text changes to Passwords don't match, and then the dropdown disappears — which looks rookie. 🙂

The proper way to handle that would be via signaling with noChange that we don't need a change in the DOM if this.passwordConfirmation.length === 0. Alternatively, there is this hack we have in brave_account_create_dialog.ts, but it's far from ideal, as the TS file is required to know about style-related stuff (i.e. name of icons).

Copy link
Member

@claucece claucece left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking awesome! Thank you @szilardszaloki !

Sign in or create a Brave account
</message>
<message name="IDS_SETTINGS_BRAVE_ACCOUNT_ROW_DESCRIPTION" translateable="false" desc="Description of the Brave Account row in the Get Started section">
A Brave account will allow you to easily sync your settings, passwords, bookmarks, etc. across all your devices and access our full range of premium products.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to update that since we are shipping accounts without support for Sync (for the time being).

<message name="IDS_SETTINGS_BRAVE_ACCOUNT_ALREADY_HAVE_ACCOUNT_SIGN_IN_BUTTON_LABEL" translateable="false" desc="Label for the button that takes the user to the 'Sign In' dialog">
Already have an account? Sign in
</message>
<message name="IDS_SETTINGS_BRAVE_ACCOUNT_SELF_CUSTODY_DESCRIPTION" translateable="false" desc="Description of the self-custody option which we provide for advanced users">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The self-custody option should not be there until we are ready to integrate with Sync.

app/brave_settings_strings.grdp Outdated Show resolved Hide resolved
app/brave_settings_strings.grdp Outdated Show resolved Hide resolved
@@ -48,6 +48,13 @@ namespace settings {

namespace {

constexpr char16_t kBraveAccountSelfCustodyLearnMoreURL[] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need self-custody this for now.

@fmarier
Copy link
Member

fmarier commented Dec 7, 2024

I don't think I saw it in this PR: does this include the gmail.con spellchecker or is that for a future PR?

Copy link
Collaborator

@bridiver bridiver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patch and browser/ui/BUILD.gn changes ok

@szilardszaloki szilardszaloki force-pushed the szilard/brave-account-settings-ui branch 3 times, most recently from 9e189ec to 24e1608 Compare December 11, 2024 02:06
@szilardszaloki
Copy link
Collaborator Author

I don't think I saw it in this PR: does this include the gmail.con spellchecker or is that for a future PR?

@fmarier Adding it to the current dropdown implementation introduces a visual artifact similar to the one being discussed here. Filed here for now — we'll likely want to export noChange from third_party/lit/v3_0/lit.ts to make our lives easier.

@szilardszaloki szilardszaloki force-pushed the szilard/brave-account-settings-ui branch 2 times, most recently from 06236ec to bbbbbed Compare December 11, 2024 15:31
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string reviewers ++

NOTE: I defer the content of the strings to @fmarier who has already left a comment 😄
But LGTM!

@fmarier
Copy link
Member

fmarier commented Dec 12, 2024

I defer the content of the strings to @fmarier who has already left a comment 😄

Contents of the strings will need to change (as per my earlier comments) but since this is not enabled by default (and not translated) we can do that later as we get closer to enabling. So it's fine for now.

@szilardszaloki szilardszaloki force-pushed the szilard/brave-account-settings-ui branch from bbbbbed to 9f6e7b5 Compare December 12, 2024 00:42
Copy link
Contributor

[puLL-Merge] - brave/brave-core@26741

Description

This PR introduces a new Brave Account feature in the browser settings. It adds several new dialogs for account creation, sign-in, and password reset, as well as a new row in the "Get started" section of settings for managing the Brave account.

Changes

Changes

  1. app/brave_settings_strings.grdp:

    • Added new localized strings for Brave Account UI elements.
  2. browser/resources/settings/BUILD.gn:

    • Updated build configuration to include new Brave Account files.
  3. browser/resources/settings/sources.gni:

    • Added new Brave Account related files to the build process.
  4. browser/resources/settings/getting_started_page/:

    • Added several new files for Brave Account functionality:
      • brave_account_browser_proxy.ts
      • brave_account_common.ts
      • brave_account_create_dialog.ts
      • brave_account_dialog.ts
      • brave_account_entry_dialog.ts
      • brave_account_forgot_password_dialog.ts
      • brave_account_row.ts
      • brave_account_sign_in_dialog.ts
    • Added corresponding CSS files for styling.
  5. browser/ui/BUILD.gn:

    • Added brave_account_handler.cc and brave_account_handler.h to the build.
  6. browser/ui/webui/brave_settings_ui.cc:

    • Added BraveAccountHandler to the WebUI message handlers.
  7. browser/ui/webui/settings/brave_account_handler.cc and brave_account_handler.h:

    • Implemented a new handler for Brave Account related WebUI messages.
  8. browser/ui/webui/settings/brave_settings_localized_strings_provider.cc:

    • Added new localized strings for Brave Account UI elements.
  9. ui/webui/resources/leo/web_components.ts:

    • Imported additional Leo web components (alert, icon, input).
sequenceDiagram
    participant User
    participant BraveSettingsUI
    participant BraveAccountHandler
    participant BraveAccountRow
    participant BraveAccountDialog

    User->>BraveSettingsUI: Open Settings
    BraveSettingsUI->>BraveAccountRow: Display Account Row
    User->>BraveAccountRow: Click "Get started"
    BraveAccountRow->>BraveAccountDialog: Show Entry Dialog
    User->>BraveAccountDialog: Choose Create Account
    BraveAccountDialog->>BraveAccountDialog: Show Create Account Dialog
    User->>BraveAccountDialog: Enter Account Details
    BraveAccountDialog->>BraveAccountHandler: Get Password Strength
    BraveAccountHandler-->>BraveAccountDialog: Return Password Strength
    User->>BraveAccountDialog: Submit Account Creation
    Note over BraveAccountDialog: Account Creation Logic (Not Implemented)
    BraveAccountDialog-->>BraveAccountRow: Update Account Status
Loading

Possible Issues

  1. The implementation of actual account creation, sign-in, and password reset functionality is not included in this PR. These will need to be implemented separately.
  2. There might be potential security considerations when handling user credentials that are not addressed in this PR.

Security Hotspots

  1. brave_account_handler.cc: The GetPasswordStrength function handles password data. Ensure that this is done securely and that the password is not logged or stored inappropriately.

@szilardszaloki szilardszaloki merged commit 750933f into master Dec 12, 2024
18 checks passed
@szilardszaloki szilardszaloki deleted the szilard/brave-account-settings-ui branch December 12, 2024 02:35
@github-actions github-actions bot added this to the 1.75.x - Nightly milestone Dec 12, 2024
@brave-builds
Copy link
Collaborator

Released in v1.75.93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/storybook-url Deploy storybook and provide a unique URL for each build puLL-Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement UIs for the "create account" and "sign in" flows in brave://settings
10 participants