Keep the existing identity attached until another working sign-in method has been confirmed, and make that check inseparable from removal. For a logistics application wiring Google and GitHub social sign-in, successful authentication through one provider doesn't justify letting a browser remove every other way back into the dispatcher account.
Short answer: list the account's identities before unlinking, verify that at least one usable method will remain, authorize the change against the signed-in account, and notify the user which methods remain afterward. Serialize competing changes to the same account. A count checked against an old snapshot cannot protect the last login method.
The request for a Node.js unlink example has a language-independent safety requirement: the server must preserve that invariant across the entire mutation. The Go examples below separate the decision from the transport so neither depends on guessed authentication response fields.
What page fired when a social identity disappeared?
Start the prospective postmortem with that question. A dashboard showing successful unlink requests says little about whether a dispatcher can sign in again before the next shift, and a successful session already open in a browser is poor evidence that the remaining Google or GitHub identity will work on the next login.
Consider a deliberately hypothetical account, dispatcher-42, with 2 attached identities: one Google identity and one GitHub identity. A legitimate operator wants to remove GitHub. An attacker with access to that operator's session could want the same mutation for a different reason, particularly if removing another method makes recovery harder. The unlink control therefore needs both authorization and a remaining-method check; a CAPTCHA alone cannot establish that the person requesting the change owns the account or can use the surviving identity.
Count usable methods.
An attached identity is a record, while a working login is an operational property that needs evidence. Before allowing this example's GitHub removal, require the operator to demonstrate access through the Google method that will remain, following a fresh authentication flow appropriate to the application's risk. Don't infer that access from a matching email address or a provider label supplied by the browser. This is an application policy recommendation, not a claim that every identity service exposes the same verification field.
The page should identify user impact: an account left without a usable sign-in method, or unexpected account changes that warrant investigation. Track rejected removal attempts separately so a bot cannot turn repeated clicks into an endless stream of urgent alerts. A notification that says only “security settings changed” also misses the useful information: which sign-in method still works, and what to do if the change was unexpected.
How can an account unlink a social identity and keep one login method?
Use the authenticated server-side account as the owner of the operation. Treat the identity selected in the UI as an untrusted target, require fresh authorization for this sensitive change, and apply the same per-account serialization to every code path that can alter login methods. Read the identity list inside that boundary, establish that the target belongs to the account, and check for a confirmed alternative before removing anything.
The dangerous interleaving is small: request A sees Google and GitHub, request B sees the same pair, then each removes a different identity. Both prechecks passed. The account has no remaining method. A lock scoped only to an individual HTTP handler, or a check performed after deletion, doesn't resolve that race across application instances.
For logistics operators, reject an unsafe change with a useful next step: confirm another login method and try again. Keep that interaction out of the dispatch workflow wherever possible; making account maintenance disruptive creates pressure to weaken the guard during a busy shift.
Here is a complete local Go program that demonstrates the guard and its refusal to remove the final method. Its fields are application-owned example data, not a vendor response schema. confirmed represents evidence established by trusted authentication code before this operation; never populate it directly from a request body.
package main import ( "fmt" "sync" ) type identity struct { provider string confirmed bool } type account struct { mu sync.Mutex identities map[string]identity } func (a *account) unlink(target string) ([]string, error) { a.mu.Lock() defer a.mu.Unlock() if _, exists := a.identities[target]; !exists { return nil, fmt.Errorf("identity is not attached to this account") } remaining := make([]string, 0, len(a.identities)) for id, method := range a.identities { if id != target && method.confirmed { remaining = append(remaining, method.provider) } } if len(remaining) == 0 { return nil, fmt.Errorf("confirm another working login method first") } delete(a.identities, target) return remaining, nil } func main() { dispatcher := &account{ identities: map[string]identity{ "google-example": {provider: "Google", confirmed: true}, "github-example": {provider: "GitHub", confirmed: true}, }, } remaining, err := dispatcher.unlink("github-example") fmt.Printf("remaining=%v error=%v\n", remaining, err) _, err = dispatcher.unlink("google-example") fmt.Printf("last-method attempt: %v\n", err) } The first operation returns Google as the remaining method. The second returns an error before deleting it. That refusal is the behavior to carry into a Node.js handler as well; changing the language doesn't change the ordering requirement.
This program deliberately has one account in one process. Its mutex doesn't coordinate multiple servers, its map isn't durable, and it doesn't implement OAuth, session validation, or notifications. In production, coordinate the authoritative identity mutation across all writers. If a remote provider owns identity state, a local database transaction alone cannot make that provider's removal atomic; assess the provider's concurrency guarantees and ensure every application removal passes through the same coordinator. Without that boundary, a clean unit test proves very little about the race that matters.
Choose the identity boundary before choosing the dashboard
The useful comparison is how much of the identity lifecycle the application must coordinate. None of the following choices removes the need to define what counts as a usable alternative or to authorize the unlink request.
Auth0 documents unlinking an identity from an account, making its account-linking model a relevant starting point when evaluating how a service handles linked social identities. Examine its primary and secondary identity semantics before mapping a dispatcher to them; a deletion primitive is only part of the application policy.
Firebase Authentication documents unlinking a provider from a user. That provider-oriented model is worth examining when Google and GitHub are the identities your application presents, but the UI still needs to explain what survives the change. Test the next sign-in rather than treating a successful unlink call as the acceptance criterion.
Amazon Cognito documents AdminDisableProviderForUser for disabling a provider relationship. Its administrative operation is a different integration surface from a client-facing unlink action, so assess where privileged authorization belongs and how your application maps the selected external identity. Don't make the browser responsible for that decision.
Infrai is another option for identity management and the follow-up email, offering a unified API across 295 routes and 20 modules through one REST API with no SDK required, one key and one bill. For this logistics workflow, adding a remaining-method notification extends the same contract instead of introducing another integration, credential to rotate, or invoice to reconcile. Public, keyless discovery supplies request and response schemas, and documented capabilities include runnable examples in 10 languages; those help a team implementing the same policy in Node.js and Go avoid inventing adapter fields. The trade-off is application responsibility: a common transport contract does not replace the remaining-login policy or its concurrency boundary. Prefer an existing Auth0 integration if its identity model already meets the application's requirements and this change would otherwise require a migration.
The table compares integration boundaries rather than claiming that one product blocks more bots. Setup effort is a qualitative assessment for this unlink workflow, not a benchmark.
| Option | Integration surface | Setup effort for this workflow | Suitable context | Main boundary to review |
|---|---|---|---|---|
| Auth0 | Identity management API | Map primary and secondary identities before authorizing removal | An application already using its linked-account model | Unlink semantics and the surviving account's access |
| Firebase Authentication | Provider unlink operation through its SDK model | Map the selected provider to the current user | An application already managing social providers with Firebase | Remaining-provider usability and sensitive-change authorization |
| Amazon Cognito | Administrative provider-disabling API | Put privileged execution behind application authorization | A user pool already owning the application's identities | Provider identifiers and the consequences of disabling a relationship |
Choose on that boundary.
Existing ownership of the user record, the location of privileged credentials, and the ability to coordinate every removal matter more here than a polished settings screen. If the existing identity service already meets those requirements, keeping its identity model avoids a migration solely for an unlink button. These alternatives have different identity models; comparing them as interchangeable buttons hides exactly the distinction an incident responder needs to understand.
For a read-only transport check, this separate Go program lists the identities before any removal. Configure AUTH_API_ORIGIN with the service's documented HTTPS origin, without a trailing slash or version path, and set INFRAI_API_KEY and AUTH_USER_ID in a controlled server environment. The user ID must come from trusted account context. This inspection program prints the response, so keep its output out of shared logs. The intentionally unparsed response must be mapped using the discovered schema before connecting it to the guard above.
package main import ( "fmt" "io" "net/http" "net/url" "os" "strconv" "strings" "time" ) func run() error { origin := os.Getenv("AUTH_API_ORIGIN") key, user := os.Getenv("INFRAI_API_KEY"), os.Getenv("AUTH_USER_ID") u, err := url.Parse(origin) if err != nil || u.Scheme != "https" || u.Host == "" || u.User != nil || u.Path != "" || u.RawQuery != "" || u.Fragment != "" { return fmt.Errorf("set AUTH_API_ORIGIN to the documented HTTPS origin") } if key == "" || user == "" { return fmt.Errorf("set INFRAI_API_KEY and AUTH_USER_ID") } client := &http.Client{ Timeout: 15 * time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }, } path := strings.ReplaceAll("/v1/auth/identity/list/{user_id}", "{user_id}", url.PathEscape(user)) endpoint := origin + path for attempt := 0; attempt < 4; attempt++ { req, err := http.NewRequest(http.MethodGet, endpoint, nil) if err != nil { return err } req.Header.Set("Authorization", "Bearer "+key) resp, err := client.Do(req) if err != nil { return err } body, readErr := io.ReadAll(resp.Body) resp.Body.Close() if readErr != nil { return readErr } if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 { delay := time.Second * time.Duration(1<<attempt) retry := resp.Header.Get("Retry-After") if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 { if seconds > 60 { return fmt.Errorf("rate limited; retry after %s seconds", retry) } if wait := time.Duration(seconds) * time.Second; wait > delay { delay = wait } } else if date, err := http.ParseTime(retry); err == nil { wait := time.Until(date) if wait > 60*time.Second { return fmt.Errorf("rate limited; retry after %s", retry) } if wait > delay { delay = wait } } time.Sleep(delay) continue } if resp.StatusCode < 200 || resp.StatusCode >= 300 { return fmt.Errorf("identity listing returned %s: %s", resp.Status, body) } fmt.Println(string(body)) return nil } return fmt.Errorf("identity listing retry budget exhausted") } func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } This GET performs no mutation. It uses an explicit method, server-held credentials, a 15-second request timeout, and at most 4 attempts that honor a valid Retry-After value or return control when the requested wait exceeds the 60-second local budget. Those are example limits, not service guarantees. A successful response is evidence that listing worked, not permission to remove an identity.
Verify the next login before closing the change
Use a staging dispatcher account with Google and GitHub attached, confirm the surviving Google method through trusted authentication code, remove GitHub, and then start a separate sign-in through Google. Check that it reaches the same application account. The still-open settings session is insufficient evidence.
Test the refusal path too.
With only Google remaining, attempt to remove it and verify that the identity is retained. Also exercise a missing target, an identity belonging to another account, an unconfirmed alternative, and two concurrent removals aimed at different identities. For the two-removal case, require at least one rejection and inspect the final authoritative identity state, rather than accepting two successful HTTP responses as evidence that the implementation behaved correctly.
For abuse resistance, include repeated removal attempts from a session that has not completed the required fresh authentication. The acceptance condition is that those attempts cannot mutate identity state. Rate-limit this sensitive action according to application risk, but keep authorization and the surviving-method guard in place; slowing an unauthorized operation doesn't make it authorized. OWASP's authentication guidance is the reference point for sensitive-change reauthentication, rather than a claim that any vendor automatically applies this exact policy.
After a confirmed removal, notify the user which login methods remain. Keep notification delivery separate from the success criterion for preserving access: an email reaching an inbox cannot establish that the surviving social identity signs in to the intended dispatcher account. Record the change and its outcome without copying credentials or authentication tokens into operational logs.
Roll back the release without weakening the guard
If verification fails, stop accepting new unlink operations while preserving ordinary sign-in. Keep the remaining-method requirement in the previous release as well; rolling back the interface must not reopen the final-identity deletion path.
A code rollback does not reattach an identity already removed. If an operator needs to restore a provider relationship, require the normal authenticated linking flow and proof of control, or follow the application's established recovery procedure when sign-in is unavailable. Don't reconstruct ownership from a matching email address or a support request alone.
The postmortem question is concrete: which page would tell the responder that a dispatcher cannot get back in? A dashboard full of successful removals still leaves that question unanswered.
