ACCESS=accounts (config/access.ts; open stays the default and behaves as before): Newznab and the catalog's releases routes name a user (apikey or the web interface's token), whose tier sets searches and NZBs per UTC day (Newznab 500/501, the catalog 429) and how far back they see (102/403). Counted in one upsert per use, so the last one can't be taken twice; caps, stats and refused requests aren't counted. Signup takes an invite (SIGNUP), which may give a tier; ace access:invite, access:tier (extends a running tier), access:suspend. The web interface signs in and shows the day's usage and the Newznab key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
774 B
TypeScript
20 lines
774 B
TypeScript
import UserTransformer from '#transformers/user_transformer'
|
|
import type { HttpContext } from '@adonisjs/core/http'
|
|
import AccessService from '#services/access_service'
|
|
|
|
export default class ProfileController {
|
|
/** The user, their tier, Newznab key and what they used today. */
|
|
async show({ auth, serialize }: HttpContext) {
|
|
const user = auth.use('api').getUserOrFail()
|
|
return serialize({ user: UserTransformer.transform(user), access: await AccessService.summary(user) })
|
|
}
|
|
|
|
/** POST /api/v1/account/api-key: a new Newznab key (the old one stops working). */
|
|
async resetApiKey({ auth }: HttpContext) {
|
|
const user = auth.use('api').getUserOrFail()
|
|
user.apiKey = AccessService.newKey()
|
|
await user.save()
|
|
return { apiKey: user.apiKey }
|
|
}
|
|
}
|