From 1b2f4d9a54a5768a0ee733a085a80881da246455 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 11 Sep 2023 07:17:00 -0500 Subject: [PATCH] accounts: return token after registering account --- src/controllers/api/accounts.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/controllers/api/accounts.ts b/src/controllers/api/accounts.ts index 1d37f709..d1bc244e 100644 --- a/src/controllers/api/accounts.ts +++ b/src/controllers/api/accounts.ts @@ -1,12 +1,12 @@ import { type AppController } from '@/app.ts'; import { Conf } from '@/config.ts'; -import { type Filter, findReplyTag, z } from '@/deps.ts'; +import { type Filter, findReplyTag, nip19, z } from '@/deps.ts'; import * as mixer from '@/mixer.ts'; import { getAuthor, getFollowedPubkeys, getFollows, syncUser } from '@/queries.ts'; import { booleanParamSchema, fileSchema } from '@/schema.ts'; import { jsonMetaContentSchema } from '@/schemas/nostr.ts'; import { toAccount, toRelationship, toStatus } from '@/transformers/nostr-to-mastoapi.ts'; -import { isFollowing, lookupAccount, Time } from '@/utils.ts'; +import { isFollowing, lookupAccount, nostrNow, Time } from '@/utils.ts'; import { paginated, paginationSchema, parseBody } from '@/utils/web.ts'; import { createEvent } from '@/utils/web.ts'; import { renderEventAccounts } from '@/views.ts'; @@ -41,7 +41,12 @@ const createAccountController: AppController = async (c) => { admin: 0, }); - return new Response(); + return c.json({ + access_token: nip19.npubEncode(pubkey), + token_type: 'Bearer', + scope: 'read write follow push', + created_at: nostrNow(), + }); } catch (_e) { return c.json({ error: 'Username already taken.' }, 422); }