Cross Events 3.0.0: sign-in through the church's Accounts
Settings -> Sign-in: check, move (everyone into Accounts with their password hashes and authenticator apps, count/hash check, then switch) and undo for 14 days. Sign-in through auth-client with a one-time handoff to Events' own token; staff roles stepped up to mfa; sign-out and back-channel logout; user.updated/export/deleted; admin 2FA reset, unlock and profile changes via Accounts; /login, /register, /forgot-password forward once moved; Events' own sign-in endpoints answer SIGN_IN_MOVED. User.accountId, AccountsSignIn. npm run test:accounts runs Events' code against the real Accounts app (11 tests); 5 new Jest tests. MIGRATING-TO-3.md, plan "Changes while building". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -156,7 +156,10 @@ async function unsubscribe(token, { channels = CHANNELS, source = 'unsubscribe_l
|
||||
if (target.userId) {
|
||||
const prefs = {};
|
||||
for (const c of channels) if (CHANNELS.includes(c)) prefs[c] = false;
|
||||
return setNewsPreferences(target.userId, prefs, { source, ip });
|
||||
const state = await setNewsPreferences(target.userId, prefs, { source, ip });
|
||||
// 3.0.0: off in the church's Accounts too, when sign-in goes through it.
|
||||
await require('../accounts/news').newsOffInAccounts(target.userId, Object.keys(prefs));
|
||||
return state;
|
||||
}
|
||||
await optOutAddress(target.channel, target.address, { source, ip });
|
||||
return { optedOut: true };
|
||||
@@ -281,6 +284,7 @@ async function whatsAppStop(rawPhone) {
|
||||
const user = await prisma.user.findFirst({ where: { phoneNumber: phone }, select: { id: true } });
|
||||
if (user) {
|
||||
await setNewsPreferences(user.id, { whatsapp: false }, { source: 'whatsapp_stop' });
|
||||
await require('../accounts/news').newsOffInAccounts(user.id, ['whatsapp']);
|
||||
return 'account';
|
||||
}
|
||||
await optOutAddress('whatsapp', phone, { source: 'whatsapp_stop' });
|
||||
|
||||
@@ -123,6 +123,9 @@ async function inactiveAccounts(before, { warned, warnedBefore, limit }, db = pr
|
||||
FROM "User" u
|
||||
WHERE u."role" = 'user'
|
||||
AND u."email" NOT LIKE '%@deleted.invalid' AND u."email" NOT LIKE '%@deleted.local'
|
||||
-- 3.0.0: people who sign in through the church's Accounts are kept or removed there
|
||||
-- (EVENTS-3.0-PLAN §7); Events still cleans up guests and anyone not linked.
|
||||
AND u."accountId" IS NULL
|
||||
) x
|
||||
WHERE last_active < $1
|
||||
AND ${warned === false ? '(warned_at IS NULL OR warned_at < last_active)' : 'warned_at >= last_active AND warned_at <= $2'}
|
||||
|
||||
Reference in New Issue
Block a user