Warning, /network/tokodon/src/content/ui/LoginFlow/AuthorizationPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com> 0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 0004 import QtQuick 0005 import QtWebView 0006 0007 import org.kde.kirigami 2 as Kirigami 0008 0009 import org.kde.tokodon 0010 0011 Kirigami.Page { 0012 id: root 0013 0014 required property var account 0015 0016 title: i18nc("@title:window", "Authorization") 0017 0018 leftPadding: 0 0019 rightPadding: 0 0020 topPadding: 0 0021 bottomPadding: 0 0022 0023 function setAuthCode(authCode) { 0024 account.setToken(authCode); 0025 pageStack.layers.clear(); 0026 pageStack.replace(mainTimeline, { 0027 name: "home" 0028 }); 0029 if (root.Window.window !== applicationWindow()) { 0030 root.Window.window.close(); 0031 } 0032 } 0033 0034 WebView { 0035 id: webView 0036 0037 anchors.fill: parent 0038 0039 url: root.account.authorizeUrl 0040 0041 onLoadingChanged: (loadRequest) => { 0042 let urlObject = new URL(loadRequest.url); 0043 0044 if (urlObject.protocol === "tokodon:") { 0045 webView.stop(); 0046 root.setAuthCode(urlObject.searchParams.get("code")); 0047 } 0048 } 0049 } 0050 0051 data: Connections { 0052 target: Controller 0053 0054 function onReceivedAuthCode(authCode) { 0055 root.setAuthCode(authCode); 0056 } 0057 } 0058 }