Hard paywall

This commit is contained in:
2026-04-28 20:35:53 +02:00
parent 05efbb9910
commit 86631a9bc0
15 changed files with 15251 additions and 14164 deletions

View File

@@ -36,11 +36,14 @@ const authPost = async (path: string, body: object): Promise<{ userId: string; e
}
throw new Error('NETWORK_ERROR');
}
const data = await response.json().catch(() => ({}));
if (!response.ok) {
const code = (data as any).code || 'AUTH_ERROR';
const msg = (data as any).message || '';
console.warn(`[Auth] ${path} failed:`, response.status, code, msg);
const data = await response.json().catch(() => ({}));
if (!response.ok) {
if (response.status === 404 && path === '/auth/apple') {
throw new Error('APPLE_BACKEND_UNAVAILABLE');
}
const code = (data as any).code || 'AUTH_ERROR';
const msg = (data as any).message || '';
console.warn(`[Auth] ${path} failed:`, response.status, code, msg);
throw new Error(code);
}
return data as any;
@@ -84,14 +87,26 @@ export const AuthService = {
return session;
},
async login(email: string, password: string): Promise<AuthSession> {
const data = await authPost('/auth/login', { email, password });
const session = buildSession(data);
await SecureStore.setItemAsync(SESSION_KEY, JSON.stringify(session));
return session;
},
async logout(): Promise<void> {
async login(email: string, password: string): Promise<AuthSession> {
const data = await authPost('/auth/login', { email, password });
const session = buildSession(data);
await SecureStore.setItemAsync(SESSION_KEY, JSON.stringify(session));
return session;
},
async signInWithApple(params: {
identityToken: string;
appleUser?: string | null;
email?: string | null;
name?: string | null;
}): Promise<AuthSession> {
const data = await authPost('/auth/apple', params);
const session = buildSession(data);
await SecureStore.setItemAsync(SESSION_KEY, JSON.stringify(session));
return session;
},
async logout(): Promise<void> {
await clearStoredSession();
},