Profile build-out (avatar + bio) + shareable bio page with QR
- Profile pane: avatar upload + bio, with a link to your public page - Wall becomes a bio page: avatar, bio, scannable join QR, line ladder, join CTA - qrcode npm dep; /api/qr renders SVG QR server-side (CSP-clean img) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+16
@@ -35,6 +35,7 @@ function newCode(taken) {
|
||||
const pub = a => a ? { email: a.email, sponsorRef: a.sponsorRef || '', code: a.code || null,
|
||||
username: a.username || null, memberId: a.memberId || 0,
|
||||
lineBannerUrl: a.lineBannerUrl || null, lineTargetUrl: a.lineTargetUrl || null,
|
||||
avatarUrl: a.avatarUrl || null, bio: a.bio || null,
|
||||
address: a.address || null, created: a.created } : null;
|
||||
const USER_RE = /^[a-zA-Z0-9_]{3,20}$/;
|
||||
const normUser = u => String(u || '').trim().toLowerCase();
|
||||
@@ -107,6 +108,14 @@ const J = {
|
||||
this.save();
|
||||
return { ok: true, account: pub(acct) };
|
||||
},
|
||||
async setProfile(e, avatarUrl, bio) {
|
||||
const acct = this.db.byEmail[e];
|
||||
if (!acct) return { error: 'No such account.' };
|
||||
if (avatarUrl !== undefined) acct.avatarUrl = avatarUrl || null;
|
||||
if (bio !== undefined) acct.bio = bio || null;
|
||||
this.save();
|
||||
return { ok: true, account: pub(acct) };
|
||||
},
|
||||
async byMemberId(id) {
|
||||
const a = Object.values(this.db.byEmail).find(x => x.memberId === Number(id));
|
||||
return a ? pub(a) : null;
|
||||
@@ -146,6 +155,7 @@ const J = {
|
||||
const rowPub = r => r ? pub({ email: r.email, sponsorRef: r.sponsor_ref, code: r.code,
|
||||
username: r.username, memberId: r.member_id || 0,
|
||||
lineBannerUrl: r.line_banner_url, lineTargetUrl: r.line_target_url,
|
||||
avatarUrl: r.avatar_url, bio: r.bio,
|
||||
address: r.address, created: Number(r.created) }) : null;
|
||||
const D = {
|
||||
async signup(e, password, ref) {
|
||||
@@ -195,6 +205,11 @@ const D = {
|
||||
await db.q('UPDATE accounts SET line_banner_url=?, line_target_url=? WHERE email=?', [bannerUrl || null, targetUrl || null, e]);
|
||||
return { ok: true, account: await this.byEmail(e) };
|
||||
},
|
||||
async setProfile(e, avatarUrl, bio) {
|
||||
if (avatarUrl !== undefined) await db.q('UPDATE accounts SET avatar_url=? WHERE email=?', [avatarUrl || null, e]);
|
||||
if (bio !== undefined) await db.q('UPDATE accounts SET bio=? WHERE email=?', [bio || null, e]);
|
||||
return { ok: true, account: await this.byEmail(e) };
|
||||
},
|
||||
async byMemberId(id) {
|
||||
const r = await db.q('SELECT * FROM accounts WHERE member_id=?', [Number(id)]);
|
||||
return rowPub(r[0]);
|
||||
@@ -295,4 +310,5 @@ async function count() { return impl().count(); }
|
||||
module.exports = { init, signup, login, ensure, byEmail, byAddress, byCode, byUsername,
|
||||
setUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, count,
|
||||
setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t),
|
||||
setProfile: (e, a, bio) => impl().setProfile(String(e || '').toLowerCase(), a, bio),
|
||||
byMemberId: id => impl().byMemberId(id) };
|
||||
|
||||
Reference in New Issue
Block a user