Stage 11: account linking & merge (email + Telegram Login Widget) (#12)
This commit was merged in pull request #12.
This commit is contained in:
@@ -22,6 +22,7 @@ import type {
|
||||
HintResult,
|
||||
Invitation,
|
||||
InvitationSettings,
|
||||
LinkResult,
|
||||
MatchResult,
|
||||
MoveResult,
|
||||
Profile,
|
||||
@@ -46,6 +47,18 @@ import {
|
||||
type MockGame,
|
||||
} from './data';
|
||||
|
||||
// emptyLinked is a "linked" LinkResult with no secondary summary or session switch.
|
||||
function emptyLinked(): LinkResult {
|
||||
return {
|
||||
status: 'linked',
|
||||
secondaryUserId: '',
|
||||
secondaryDisplayName: '',
|
||||
secondaryGames: 0,
|
||||
secondaryFriends: 0,
|
||||
session: null,
|
||||
};
|
||||
}
|
||||
|
||||
const POOL: Record<Variant, string> = {
|
||||
english: 'AAAAEEEEIIIOONNRRTTLLSSUDGBCMPFHVWYK',
|
||||
russian: 'ОООААЕЕИИННТТСРРВЛКМДПУЯЫЬГЗБ',
|
||||
@@ -415,10 +428,35 @@ export class MockGateway implements GatewayClient {
|
||||
Object.assign(this.profile, p);
|
||||
return { ...this.profile };
|
||||
}
|
||||
async emailBindRequest(_email: string): Promise<void> {}
|
||||
async emailBindConfirm(_email: string, _code: string): Promise<Profile> {
|
||||
// --- account linking & merge (Stage 11) ---
|
||||
async linkEmailRequest(_email: string): Promise<void> {}
|
||||
async linkEmailConfirm(email: string, _code: string): Promise<LinkResult> {
|
||||
// An address containing "merge" stands in for one already owned by another
|
||||
// account, so the mock can drive the irreversible-merge confirmation.
|
||||
if (email.includes('merge')) {
|
||||
return {
|
||||
status: 'merge_required',
|
||||
secondaryUserId: 'mock-secondary',
|
||||
secondaryDisplayName: 'Ann',
|
||||
secondaryGames: 7,
|
||||
secondaryFriends: 3,
|
||||
session: null,
|
||||
};
|
||||
}
|
||||
this.profile.isGuest = false;
|
||||
return { ...this.profile };
|
||||
return emptyLinked();
|
||||
}
|
||||
async linkEmailMerge(_email: string, _code: string): Promise<LinkResult> {
|
||||
this.profile.isGuest = false;
|
||||
return { ...emptyLinked(), status: 'merged' };
|
||||
}
|
||||
async linkTelegram(_data: string): Promise<LinkResult> {
|
||||
this.profile.isGuest = false;
|
||||
return emptyLinked();
|
||||
}
|
||||
async linkTelegramMerge(_data: string): Promise<LinkResult> {
|
||||
this.profile.isGuest = false;
|
||||
return { ...emptyLinked(), status: 'merged' };
|
||||
}
|
||||
async statsGet(): Promise<Stats> {
|
||||
return { ...this.stats };
|
||||
|
||||
Reference in New Issue
Block a user