mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Use token authentication for API requests.
This commit is contained in:
parent
bff8806b61
commit
96bd7e5b47
34 changed files with 198 additions and 153 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { getWebsiteByShareId } from 'lib/queries';
|
||||
import { ok, notFound, methodNotAllowed } from 'lib/response';
|
||||
import { createToken } from 'lib/crypto';
|
||||
|
||||
export default async (req, res) => {
|
||||
const { id } = req.query;
|
||||
|
|
@ -8,7 +9,10 @@ export default async (req, res) => {
|
|||
const website = await getWebsiteByShareId(id);
|
||||
|
||||
if (website) {
|
||||
return ok(res, website);
|
||||
const websiteId = website.website_id;
|
||||
const token = await createToken({ website_id: websiteId });
|
||||
|
||||
return ok(res, { websiteId, token });
|
||||
}
|
||||
|
||||
return notFound(res);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue