Skip to content

Conversation

@TigerInYourDream
Copy link
Contributor

@TigerInYourDream TigerInYourDream commented Sep 5, 2025

Summary

Implemented a complete user registration flow for Matrix accounts with support for both password-based and SSO registration methods.

Key Features

  • Full registration screen UI with modern design
  • Dual registration methods:
    • Password-based registration for custom homeservers
    • SSO registration via Google OAuth for matrix.org
  • Smart homeserver selection with automatic mode switching
  • Comprehensive form validation:
    • Username requirement checking
    • Password minimum length (8 characters)
    • Password confirmation matching
    • Custom homeserver URL validation
  • Registration status modal with real-time feedback
  • SSO state management synchronized with login screen
  • Clean error handling with user-friendly notifications

Technical Implementation

  • Follows Element's approach: SSO flow shared between login and registration
  • Matrix server automatically handles account creation vs login based on OAuth identity
  • Integrated with existing authentication infrastructure
  • Consistent UX patterns with login screen
  • Simplified UIA handling (supports m.login.dummy flow)

UI/UX Improvements

  • Clear visual feedback during registration process
  • Disabled button states to prevent duplicate submissions
  • Informative status messages during SSO flow
  • Responsive modal dialogs for registration status
  • Consistent styling with existing Robrix design language

okapii and others added 7 commits February 6, 2024 14:54
## Summary
Implemented a complete user registration flow for Matrix accounts with support for both password-based and SSO registration methods.

## Key Features
- Full registration screen UI with modern design
- Dual registration methods:
  - Password-based registration for custom homeservers
  - SSO registration via Google OAuth for matrix.org
- Smart homeserver selection with automatic mode switching
- Comprehensive form validation:
  - Username requirement checking
  - Password minimum length (8 characters)
  - Password confirmation matching
  - Custom homeserver URL validation
- Registration status modal with real-time feedback
- SSO state management synchronized with login screen
- Clean error handling with user-friendly notifications

## Technical Implementation
- Follows Element's approach: SSO flow shared between login and registration
- Matrix server automatically handles account creation vs login based on OAuth identity
- Integrated with existing authentication infrastructure
- Consistent UX patterns with login screen
- Simplified UIA handling (supports m.login.dummy flow)

## UI/UX Improvements
- Clear visual feedback during registration process
- Disabled button states to prevent duplicate submissions
- Informative status messages during SSO flow
- Responsive modal dialogs for registration status
- Consistent styling with existing Robrix design language

## Testing Checklist
- [x] Password registration with custom homeserver
- [x] SSO registration with matrix.org
- [x] Form validation (empty fields, password strength, confirmation)
- [x] Modal display and dismissal
- [x] Error handling and user notifications
- [x] Button state management during async operations
@TigerInYourDream TigerInYourDream changed the title Add comprehensive user registration screen with SSO support Add user registration screen with SSO support Sep 5, 2025
@TigerInYourDream TigerInYourDream changed the title Add user registration screen with SSO support Feature/register Support new account creation/registration Sep 5, 2025
- Use if-let instead of match for single pattern
- Replace useless format! with to_string()
@TigerInYourDream TigerInYourDream force-pushed the feature/register-new branch 2 times, most recently from 3a8c22c to 4ced188 Compare September 8, 2025 09:05
…ling

Major improvements to registration screen:

1. SSO Registration Support:
   - Added source-aware SSO handling with is_registration flag
   - Register and login screens now have independent action flows
   - Proper modal display during SSO authentication
   - Automatic modal updates with status messages

2. Modal Handling Fixes:
   - Fixed non-clickable Cancel/Abort buttons in registration modals
   - Implemented proper was_internal pattern for modal close events
   - Added button mask state (gray out) during processing
   - Correct modal text for password vs SSO registration

3. UI/UX Consistency:
   - Unified modal styles between login and register screens (285px width)
   - Consistent padding, spacing, colors (#CCC background)
   - Matching title sections and button styles
   - Unified outer screen styles (#FFF background)

4. Code Quality:
   - Simplified RegisterAction enum (removed redundant variants)
   - Complete decoupling between login and register SSO flows
   - Clear documentation of SSO action handling architecture
   - Fixed all layout and z-index issues

Technical details:
- SpawnSSOServer now includes is_registration flag
- sliding_sync.rs sends appropriate actions based on source
- Each screen only processes its own action types
- Modal shows immediately on SSO button click for better UX
- Close registration modal after successful password registration
  Previously the modal remained invisible but active, blocking UI interactions

- Prevent false offline notifications for normal sync states
  Only Error, Terminated, and Offline states now trigger connection error popups
  Idle and Running states are normal operational states

This fixes issues where users would see incorrect error messages after
registration when the sync service is actually working properly.
Signed-off-by: Alvin <zyzzz0928@gmail.com>
Resolved conflicts in:
- src/app.rs: Integrated register functionality with updated imports and view logic
- src/home/main_desktop_ui.rs: Updated to use ids! macro
- src/home/rooms_list_header.rs: Preserved enhanced offline state handling with ids! macro
- src/sliding_sync.rs: Merged register support with new main features (link preview, tombstone)
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a comprehensive user registration feature for Matrix accounts, supporting both password-based registration for custom homeservers and SSO registration (via Google OAuth) for matrix.org. The implementation follows Element's approach where the SSO flow is shared between login and registration, with the Matrix server automatically determining whether to create a new account or log in an existing user.

Key Changes

  • New registration screen with dual registration modes (password/SSO) and homeserver selection
  • Registration logic with UIA (User-Interactive Authentication) handling for m.login.dummy and m.login.registration_token flows
  • SSO flow enhancement to support both login and registration contexts with dedicated action types

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
src/sliding_sync.rs Adds register_user() function for password registration with UIA support, new MatrixRequest::Register variant, and enhances spawn_sso_server() to handle both login and registration
src/register/register_screen.rs Complete registration UI with homeserver selection, form validation, password/SSO modes, and state management
src/register/register_status_modal.rs Modal dialog for displaying registration progress with cancel functionality
src/register/mod.rs Module definition for registration components
src/app.rs Navigation handling between login/register screens and registration success flow
src/login/login_screen.rs Replaces external signup URL with navigation to new register screen
src/lib.rs Adds register module declaration
src/home/main_desktop_ui.rs Adds state reset to prevent dock restoration issue
src/home/rooms_list_header.rs Refines offline notification logic to avoid spurious error popups

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 337 to 338
// Don't save the session here - it will be saved when we convert to LoginBySSOSuccess
// This avoids duplicate session persistence
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Inconsistent comment: The comment on lines 337-338 states "Don't save the session here - it will be saved when we convert to LoginBySSOSuccess". However, this comment is placed in the password-based registration flow, not the SSO flow.

The password registration returns a client/session that gets passed to LoginBySSOSuccess on line 709, so the comment makes sense in context but could be clearer. Consider moving or clarifying this comment to explain that session persistence happens in the login flow that follows.

Suggested change
// Don't save the session here - it will be saved when we convert to LoginBySSOSuccess
// This avoids duplicate session persistence
// Don't save the session here—session persistence is handled in the login flow that follows
// (e.g., when passing to LoginBySSOSuccess). This avoids duplicate session persistence.

Copilot uses AI. Check for mistakes.
@TigerInYourDream
Copy link
Contributor Author

State Transition: Registration → Login

Background

In the Matrix SDK, successful registration also means successful login. This is documented in https://docs.rs/matrix-sdk/0.16.0/matrix_sdk/authentication/matrix/struct.MatrixAuth.html#method.register and verified by
Element's behavior—after registration, users go directly to the chat interface.

The Challenge

Robrix uses different action types for registration (RegisterAction) and login (LoginAction). After successful registration, we need to initialize all global state (CLIENT, SLIDING_SYNC, room lists, etc.) which is already
implemented in the login flow.

Solution

We reuse LoginBySSOSuccess to handle post-registration initialization:

// After successful registration, trigger the login success flow
Cx::post_action(LoginAction::LoginBySSOSuccess(client));

Why LoginBySSOSuccess instead of LoginByPasswordResult?

Aspect LoginByPasswordResult LoginBySSOSuccess
Makes network request Yes (calls login()) No
Expects authenticated client No Yes
Use case Username/password auth Pre-authenticated client

Registration already authenticates us—we have a valid client and session. LoginBySSOSuccess simply:

  1. Saves the session locally
  2. Initializes global state (CLIENT, SLIDING_SYNC, etc.)
  3. Navigates to the main app

The name LoginBySSOSuccess is somewhat misleading—it's effectively a "UseAuthenticatedClient" action that works for any pre-authenticated client (SSO, registration, restored session, etc.).

@tyreseluo tyreseluo added the waiting-on-review This issue is waiting to be reviewed label Jan 16, 2026
@kevinaboos
Copy link
Member

Hi @TigerInYourDream, just wanted to let you know that I did see this PR is ready for review, but it'll probably be a while before I can get to it due to the comparatively low priority of this feature. I do appreciate your work here though!

in the meantime, can you fully prepare it for review by addressing all existing comments (marking the completed ones as resolved, and leaving replies/comments on the ones that aren't resolved yet), as well as fixing the conflicts? thanks.

Resolved conflict in src/sliding_sync.rs by keeping both:
- RegisterAction import from feature branch
- AvatarState import from main branch
@TigerInYourDream
Copy link
Contributor Author

Hi @TigerInYourDream, just wanted to let you know that I did see this PR is ready for review, but it'll probably be a while before I can get to it due to the comparatively low priority of this feature. I do appreciate your work here though!

in the meantime, can you fully prepare it for review by addressing all existing comments (marking the completed ones as resolved, and leaving replies/comments on the ones that aren't resolved yet), as well as fixing the conflicts? thanks.

Hi @kevinaboos,

Thanks for the update I completely understand the priority considerations.

I've just resolved the merge conflicts with the latest main branch. I'll go through all the existing review comments now and:

  • Mark the completed ones as resolved
  • Add replies to any that need clarification or further discussion

The PR should be fully ready for review whenever you have time. No rush at all - I appreciate you taking the time to review this when you can.

TigerInYourDream and others added 4 commits January 22, 2026 11:03
1. Improve URL validation in register screen
   - Use url::Url::parse() for proper URL validation
   - Support both full URLs and domain-only input
   - More robust than simple string prefix checking

2. Enhance registration token error detection
   - Check for both error message and M_INVALID_PARAM error code
   - Add clearer documentation about SDK limitations
   - More resilient to SDK error message changes
Remove duplicate modal closing and state reset when handling SSO
registration success. The cleanup is now done only once in the
RegistrationSuccess action handler, making the code flow clearer
and avoiding potential state inconsistencies.

Before: Cleanup happened twice (once when posting action, once when handling)
After: Cleanup happens once in the centralized action handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-on-review This issue is waiting to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants