fix: multiple redirect uri support
This commit is contained in:
parent
6db8ad14e2
commit
440d961ab4
1 changed files with 5 additions and 2 deletions
|
@ -17,7 +17,8 @@ export class AuthHelpers {
|
|||
const scopes = (typeof body.scopes === "string"
|
||||
? body.scopes.split(" ")
|
||||
: body.scopes) ?? ["read"];
|
||||
const redirect_uris = body.redirect_uris?.split("\n") as
|
||||
// Mastodon takes any whitespace chars or line breaks as separator
|
||||
const redirect_uris = body.redirect_uris?.split(/[\s\n]/) as
|
||||
| string[]
|
||||
| undefined;
|
||||
const client_name = body.client_name;
|
||||
|
@ -94,7 +95,9 @@ export class AuthHelpers {
|
|||
400,
|
||||
"Cannot request more scopes than application",
|
||||
);
|
||||
if (!app.callbackUrl?.startsWith(body.redirect_uri))
|
||||
|
||||
const callbackUrls = app.callbackUrl?.split("\n") ?? [];
|
||||
if (!callbackUrls.some(url => url.startsWith(body.redirect_uri)))
|
||||
throw new MastoApiError(400, "Redirect URI not in list");
|
||||
const secret = generateSecureRandomString(32);
|
||||
const token = await AccessTokens.insert({
|
||||
|
|
Loading…
Reference in a new issue