Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@profullstack/openprofile": "^0.2.0",
"@profullstack/partners": "^0.2.0",
"@profullstack/player": "0.16.0",
"@profullstack/profile": "0.1.6",
"@profullstack/profile": "0.1.7",
"@profullstack/rssamplifier": "workspace:*",
"@profullstack/submit-feed": "^0.1.3",
"@profullstack/x402-gateway": "^0.16.1",
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/account/ProfileForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function ProfileForm({ initial }) {
<form className="submit-box" onSubmit={save}>
{/* Keyed on the saved values so a save re-renders the inputs with what
the server normalized them to. */}
<ProfileFields key={JSON.stringify(values)} defaultValues={values} errors={errors} idPrefix="account-" />
<ProfileFields key={JSON.stringify(values)} defaultValues={values} errors={errors} idPrefix="account-" importOpenProfile/>
<div className="submit-actions">
<button type="submit" disabled={busy}>
{busy ? 'Saving…' : 'Save profile'}
Expand Down
13 changes: 11 additions & 2 deletions apps/web/src/app/api/v1/coinpay/oauth/callback/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { cookies } from 'next/headers';
import { finishSignIn } from '@profullstack/coinpay-onboard/oauth';
import { signInWithCoinpay, startSession, takeCoinpayCallback } from '@rssamplifier/auth';
import { saveOpenProfileContact } from '@profullstack/profile';
import { profileStore, signInWithCoinpay, startSession, takeCoinpayCallback } from '@rssamplifier/auth';

import { db } from '../../../../../../lib/db.js';
import { currentUser, requestMeta, setSessionCookie } from '../../../../../../lib/auth.js';
Expand Down Expand Up @@ -44,6 +45,7 @@ export async function GET(req) {
}

let profile;
let openProfileUrl = null;
try {
const result = await finishSignIn({
code,
Expand All @@ -54,6 +56,7 @@ export async function GET(req) {
redirectUri: config.redirectUri,
});
profile = { sub: result.sub, email: result.email, name: result.name };
openProfileUrl = typeof result.userinfo.openprofile_url === 'string' ? result.userinfo.openprofile_url : null;
} catch (err) {
console.error('[coinpay] sign-in failed:', err?.message ?? err);
return seeOther(linking ? '/account?coinpay=failed#coinpay' : '/login?error=coinpay-failed');
Expand All @@ -63,7 +66,13 @@ export async function GET(req) {
if (!outcome.ok) {
return seeOther(linking ? `/account?coinpay=${outcome.error}#coinpay` : `/login?error=coinpay-${outcome.error}`);
}
if (linking) return seeOther('/account?coinpay=connected#coinpay');
if (linking) {
if (openProfileUrl) {
try { await saveOpenProfileContact(profileStore(db()), String(outcome.userId), openProfileUrl); }
catch { console.warn('[coinpay] OpenProfile import skipped'); }
}
return seeOther('/account?coinpay=connected#coinpay');
}

const meta = await requestMeta();
const { token } = await startSession(db(), outcome.userId, meta);
Expand Down
4 changes: 3 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading