Users don't match up across your app, mini program, and H5: what makes a cross-platform account system reliable?
The conclusion first: the hard part of unifying accounts across platforms is not "letting users log in". It is confirming that two entry points belong to the same person, and that this judgment can be revoked and traced. A reasonably robust default: maintain your own internal user_id as the only primary key, and demote phone numbers, WeChat OpenID, UnionID, Apple ID, and device identifiers to login credentials attached beneath it. Every login then does exactly one thing: resolve a credential into a user_id.
Run it the other way, with OpenID or a phone number as the primary key, and every platform you add forces a data-model change, and every change forces a migration plus a batch of conflicting accounts.
There are preconditions. With a single entry point, a small user base, and no paid entitlements, using a phone number as the account can work for a long time. But once the same person holds orders, balances, membership tiers, or content on two platforms, the primary-key design becomes an irreversible decision. A few symptoms are enough to tell whether you have reached that point.
1. "Accounts that don't match up" shows up in four ways
Support cannot find the order. A user ordered inside the mini program. Support searches the back office by phone number and gets three accounts, opens each one, and finally confirms the order by order number. Do that dozens of times a day and you are paying the cost of an unconnected account system.
Entitlements don't follow the person. Membership tier, coupons, points, purchased courses, and saved content all hang off a single account record. A coupon claimed on platform A is not recognized on platform B; a tier upgraded on B still reads as an ordinary user on A. Operations counts an existing customer as a new one, and ad budget goes to people who already bought.
Messages are duplicated or missed. The same person gets the same push three times, or an important notice only reaches the platform he rarely opens, because the main account lives in the app while the business data lives in the mini program.
Analytics drift. The dashboard shows 100,000 registered users when the real headcount may be 60,000; repeat-purchase rate, retention, and revenue per customer are all skewed. Every later decision built on those numbers sits on a broken foundation.
2. Root cause: the ID WeChat gives you is an in-app identifier, not a user ID
OpenID is the identifier most often mistaken for a primary key in the WeChat ecosystem. It is unique, but only within one application: the same person is one OpenID in your Official Account, a different one in your mini program, and a third one in the mobile app registered under WeChat Open Platform.
What stays stable across applications is UnionID. Under the WeChat Open Platform mechanism, the same person keeps the same UnionID across multiple applications under the same Open Platform account, provided those applications are all bound to that account and the authorization returns a UnionID. Miss any precondition and UnionID comes back empty.
The result is a familiar situation: three platforms, three sets of OpenIDs, three user tables in the back office. Operations sees "three users", while the user experiences "I have an account in all three of your places, and none of them recognize each other."
A phone number looks more reliable, but it is a contact method, not an identity. One person with several numbers, a changed number, a number recycled and reissued by the carrier, a number shared by family members, a deactivated corporate number, inconsistent international formats: all of these happen. Make the phone number the primary key and "changing the number means changing the person": old orders, old balances, and old entitlements stay locked inside an account nobody can sign into again.
3. Six checks for whether an account system is reliable
| Dimension | What to check | Why it drives long-term cost |
|---|---|---|
| Primary key separate from credentials | Is the user table keyed on your own ID or on an external ID? | Decides whether a new platform means "add a row" or "change the model" |
| Credential uniqueness | Is there a unique constraint on type + identifier? | Without it you get duplicate accounts per person, fixable only by hand |
| Merge rules | On conflict, do you overwrite, reject, or run a merge flow? | Silent overwrites lose orders and balances, unrecoverably |
| Unbindability | Does the account still exist after a credential is unbound? | Decides whether changing a phone or WeChat account loses the user |
| Session policy | Simultaneous sign-in across platforms, or global sign-out? | A security-versus-experience trade-off that must be decided up front |
| Traceability | Can you reconstruct which credential a login used and which accounts were merged? | The only evidence when something breaks, and required for audits |
The first two are the foundation. The last four decide whether the system survives real operations.
4. Four common approaches and what each one solves
Option 1: Phone number plus verification code as the account
The least work: the user types a number, receives a code, and is in. Fine for a single-platform, simple product without cross-platform entitlements, and a useful fallback login for every other option.
The cost is that phone numbers change. Build the rebinding path in advance: verify the old number, verify the new one, and keep a rollback state in between. When the old number is already deactivated, fall back to manual review or face verification rather than opening the door.
Option 2: Anchor on UnionID
If the business lives inside the WeChat ecosystem (Official Account + mini program + H5 inside WeChat), identifying people by UnionID is the cheapest route: one UnionID maps to one internal account, and each platform's own OpenID becomes an attached credential.
State the limits up front: UnionID is only valid under a single Open Platform entity. A second mini program registered under a different entity, or a migration to another Open Platform account, breaks the match. It also does not cover logins outside WeChat: Apple sign-in in the app, Android vendor accounts, and your own phone-number login all still have to attach to the same account.
Option 3: Build your own unified user center
This is the usual landing point for multi-channel, multi-platform operations: one user table plus one credential table, where credential types include phone number, WeChat OpenID/UnionID, Apple ID, WeCom, and email, each row carrying app_id, verification time, and status. Orders, membership, and content recognize only user_id.
The cost is an extra service and an extra call layer, plus someone who owns the merge and unbind rules long term. The payoff: a new platform or a new login method means one new credential type, with no change on the business side.
Option 4: Use a ready-made identity service
Cloud account hosting, open-source identity middleware, and managed identity providers abroad all supply login, tokens, and multi-factor authentication. A fit for scenarios that are standardized and need no deep customization of account behavior.
Watch the boundary: hosting solves authentication, but business rules such as "which account should this order belong to" and "how is the balance split when accounts merge" are still yours to define. Outsourcing authentication is not outsourcing the account system.
| Approach | Primary key | Fits when | Main cost |
|---|---|---|---|
| Phone number as account | Phone number | Single platform, light business, fast launch | Changing the number changes the person; conflicts once you add platforms |
| UnionID anchor | UnionID | Purely inside WeChat, one entity | Misses cross-entity cases and non-WeChat logins |
| Own user center | Internal user_id | Multiple channels, long-term membership | Extra build and maintenance up front |
| Ready-made identity service | Provider user id | Standard login needs, fast integration | Business rules still have to be built |
5. Binding and unbinding: where incidents concentrate
Verify ownership before binding. A phone number needs a verification code; third-party authorization needs the callback state and origin checked; one code must not be reused. Skip this and you let anyone attach an arbitrary phone number to their own account.
One credential belongs to exactly one account. Enforce it with a database unique constraint, not with a code check. Under concurrency, code checks will eventually miss. A constraint makes the conflict visible, and that is a good thing.
Never overwrite on conflict. When a user signs in with a WeChat account already bound to account B, the system should say "this WeChat account is bound to another account; merge?" instead of quietly moving the credential to A. A silent overwrite leaves B without a login method, and the next day that user cannot get in.
Write the merge ownership rules down. Go item by item: orders, balance, coupons, invoices, purchased content, after-sales tickets. After merging, does each belong to the primary account, stay with the original, or merge by time? Balance and coupons involve money and marketing cost and usually need the business owner's sign-off; the ownership of issued invoices cannot be changed casually. The rules must be reversible: a wrong merge has to be separable.
Unbinding must not orphan an account. Keep at least one usable credential per account. When a user unbinds the only WeChat account, the right sequence is to guide him to bind a phone number first, then unbind; otherwise the account becomes unreachable and only manual recovery is left.
Deletion runs in the reverse order. When a user deletes an account, unbind third-party credentials and cancel subscriptions and auto-renewals first, then handle data retention and deletion, and only then mark the account deleted. Invert that order and you get "account deleted but still being charged". Retention periods follow the applicable personal-information and transaction-record requirements; let legal confirm the exact years instead of guessing.
6. Choose the path that matches your situation
Only an Official Account and a mini program, no app for two years. Anchor on UnionID with phone number as fallback, and skip a separate user center for now. Still key the user table on an internal ID rather than UnionID itself, so the future needs no migration.
An app already exists, and cross-platform membership is next. Go straight to your own user center. The app involves Apple sign-in, Android vendor accounts, and your own phone-number login; WeChat covers only part of that, and UnionID cannot carry it alone.
Several mini programs under one entity, for different business lines. UnionID works, provided all of them are bound to the same Open Platform account. Across entities (different licensed companies in a group, for example) it does not, so unify through phone numbers or other credentials and settle account ownership in the contract.
Business customers, with employees holding accounts. Personal-account logic does not apply. Enterprise procurement needs organization and tenant dimensions: one tenant per company, employees belonging to a tenant, permissions assigned inside the tenant, and offboarding as member removal rather than account deletion. Force a consumer account model onto B2B and permissions will end up a mess.
Users overseas. Apple and Google sign-in dominate, and account deletion and data export requirements differ by region. For overseas projects, reserve region and credential-type fields in the user center from the start.
7. Six steps you can follow
- Inventory what you have. List every table that stores user information: what the primary key is, whether there is a phone field, whether numbers are plaintext or encrypted, whether a unique index exists. This step routinely exposes the same phone number recorded once in two different tables.
- List the platforms and login methods you may add in the next 12 months. This decides how many credential types to allow for, not what to build now.
- Fix the primary key and credential table, then run a conflict drill. In a test environment, create duplicate data: the same phone number twice, one UnionID attached to two accounts, a credential pointing at a deleted account. See whether the system rejects it, errors, or silently overwrites. The drill says more than the design document.
- Turn merge and unbind rules into an executable document. State who may act, whether a second confirmation is required, whether it can be undone, and how errors are remedied. Vague rules always end up as verbal decisions by support staff.
- Accept against these criteria. The same person sees the same order after signing in on the mini program and the app; unbinding WeChat still leaves phone-number login working; binding a credential that belongs to someone else is explicitly rejected with a merge entry point; balances and order counts reconcile after a merge; every login can be traced in the logs to the credential used. Fail these and going live only pushes the problem to support.
- Switch gradually. Connect the mini program and H5 first, watch conflict volume for two weeks, then switch the app. A single full cutover concentrates conflicts into one week.
8. Final thoughts
A cross-platform account system does not have to be perfect on day one, but the primary key and the credential layer should be separated from the start. Separated, adding a platform is addition. Not separated, adding a platform is migration.
Wavesteam builds custom apps, mini programs, enterprise management systems, and AI applications. The account system is usually among the first technical decisions we confirm after kickoff, because it touches orders, permissions, payments, and the ownership of every later piece of data, and the later it changes the more it costs. We start by reviewing your existing user data plus the platforms and login methods you plan to add, then deliver the primary-key and credential design, merge and unbind rules, and an acceptance checklist, handing over the table structure, API documentation, and third-party accounts so the account system is not a black box only the original vendor can maintain. If you are stuck with a separate set of users on each platform, send us your user tables and platform list and we will first judge whether you need a credential layer or a one-time merge migration.
Common follow-up questions
Will a user who signs in with both WeChat and a phone number end up with two accounts?
Yes, and without intervention they certainly will. The fix is to prompt binding after login: a user who arrives through WeChat binds a phone number when reaching a step that needs contact details, and a user who arrives by phone number is prompted to bind WeChat at a suitable moment. Both credentials attach to the same user_id, and afterwards either sign-in returns the same person.
What if UnionID is not returned?
Check three preconditions first: are all applications bound to the same Open Platform account, did the user's authorization include the required scope, and is the server exchanging it with the correct credentials. When it still does not come back, do not fall back to using OpenID as the primary key, which immediately creates duplicate accounts. Safer: create a temporary account keyed on the phone number, or on OpenID plus app_id, and merge once a UnionID becomes available.
Historical data already contains duplicate accounts. Can they be merged automatically?
What you can automate is detection plus recommendation, not the merge itself. Strong signals such as an identical phone number or identical UnionID can be matched automatically, but data carrying money or legal responsibility, such as orders, balances, invoices, and after-sales records, needs a human to confirm the merge. The usual sequence: run a comparison to produce a list, spot-check the rules by hand, then execute in batches, each reversible.
Should multi-platform login use single sign-on, so signing out on one platform signs out all?
It depends on the business. Highly sensitive contexts such as finance and internal admin usually require all sessions to drop when the password changes or risk control triggers; content and e-commerce products generally let each platform stay online independently, to avoid the annoyance of signing out on the phone and being ejected from the tablet too. Build the capability first: tokens that can be invalidated in bulk per user. Then configure the policy per business, and do not hard-wire it into any single platform.
Sources and notes
- The scope and binding conditions of WeChat OpenID and UnionID follow the WeChat Open Platform and mini program documentation on user identifiers and authorized login. This article describes the mechanism as a general rule; for specific API behavior and current version limits, refer to the official documentation.
- The account design, merge, and unbind methods here are engineering practice recommendations, not legal or compliance advice. Retention periods for personal information and specific deletion procedures must be confirmed against applicable regulations and the jurisdictions where you operate.
- This article contains no customer data, project names, or performance promises. The choice of approach depends on your current user scale, number of platforms, and business type.