mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 11:27:31 -07:00
[mastodon-client] Fix double-urlencoded redirect URLs
This fixes login in elk.zone
This commit is contained in:
parent
e5dc89c1cb
commit
2c0a006af6
1 changed files with 16 additions and 2 deletions
|
@ -102,6 +102,20 @@ if ($i) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getUrlParams = () =>
|
||||||
|
window.location.search
|
||||||
|
.substring(1)
|
||||||
|
.split("&")
|
||||||
|
.reduce((result, query) => {
|
||||||
|
const [k, v] = query.split("=");
|
||||||
|
result[k] = decodeURIComponent(v);
|
||||||
|
return result;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
const redirectUri = getUrlParams()['redirect_uri'];
|
||||||
|
if (redirectUri !== props.redirect_uri)
|
||||||
|
console.warn(`Mismatching redirect_uris between props (${props.redirect_uri}) and getUrlParams (${redirectUri})`);
|
||||||
|
|
||||||
function getIcon(p: string) {
|
function getIcon(p: string) {
|
||||||
if (p.startsWith("write")) return "pencil-simple";
|
if (p.startsWith("write")) return "pencil-simple";
|
||||||
else if(p.startsWith("read")) return "eye";
|
else if(p.startsWith("read")) return "eye";
|
||||||
|
@ -114,7 +128,7 @@ async function accept(): Promise<void> {
|
||||||
state = "waiting";
|
state = "waiting";
|
||||||
const res = await os.apiJson("v1/iceshrimp/auth/code", {
|
const res = await os.apiJson("v1/iceshrimp/auth/code", {
|
||||||
client_id: props.client_id,
|
client_id: props.client_id,
|
||||||
redirect_uri: props.redirect_uri,
|
redirect_uri: redirectUri,
|
||||||
scopes: _scopes,
|
scopes: _scopes,
|
||||||
}).catch(r => {
|
}).catch(r => {
|
||||||
message = r;
|
message = r;
|
||||||
|
@ -125,7 +139,7 @@ async function accept(): Promise<void> {
|
||||||
if (props.redirect_uri !== 'urn:ietf:wg:oauth:2.0:oob') {
|
if (props.redirect_uri !== 'urn:ietf:wg:oauth:2.0:oob') {
|
||||||
state = "accepted";
|
state = "accepted";
|
||||||
location.href = appendQuery(
|
location.href = appendQuery(
|
||||||
props.redirect_uri,
|
redirectUri,
|
||||||
query({
|
query({
|
||||||
code: res.code,
|
code: res.code,
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in a new issue