Merge pull request 'fix: build proper callback url of mastodon oauth' (#9764) from nmkj/calckey:fix-oauth-redirect into develop
Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9764
This commit is contained in:
commit
a3a7e43686
1 changed files with 4 additions and 2 deletions
|
@ -88,8 +88,10 @@ export default defineComponent({
|
||||||
const getUrlParams = () => window.location.search.substring(1).split('&').reduce((result, query) => { const [k, v] = query.split('='); result[k] = decodeURI(v); return result; }, {});
|
const getUrlParams = () => window.location.search.substring(1).split('&').reduce((result, query) => { const [k, v] = query.split('='); result[k] = decodeURI(v); return result; }, {});
|
||||||
const isMastodon = !!getUrlParams().mastodon
|
const isMastodon = !!getUrlParams().mastodon
|
||||||
if (this.session.app.callbackUrl && isMastodon) {
|
if (this.session.app.callbackUrl && isMastodon) {
|
||||||
const stateParam = !!getUrlParams().state ? `&state=$(getUrlParams().state)` : '';
|
const callbackUrl = new URL(this.session.app.callbackUrl);
|
||||||
location.href = `${this.session.app.callbackUrl}?code=${this.session.token}${stateParam}`;
|
callbackUrl.searchParams.append("code", this.session.token);
|
||||||
|
if (!!getUrlParams().state) callbackUrl.searchParams.append("state", getUrlParams().state);
|
||||||
|
location.href = callbackUrl.toString();
|
||||||
} else if (this.session.app.callbackUrl) {
|
} else if (this.session.app.callbackUrl) {
|
||||||
const url = new URL(this.session.app.callbackUrl);
|
const url = new URL(this.session.app.callbackUrl);
|
||||||
if (['javascript:', 'file:', 'data:', 'mailto:', 'tel:'].includes(url.protocol)) throw new Error('invalid url');
|
if (['javascript:', 'file:', 'data:', 'mailto:', 'tel:'].includes(url.protocol)) throw new Error('invalid url');
|
||||||
|
|
Loading…
Reference in a new issue