Fixed android login

This commit is contained in:
WardPearce
2024-05-03 18:21:34 +12:00
parent 630b0ee66d
commit c381b17eb2
13 changed files with 78 additions and 2 deletions
+3
View File
@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
@@ -9,6 +9,7 @@ android {
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-app')
implementation project(':capacitor-browser')
}
@@ -22,6 +22,13 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="materialious-auth" />
</intent-filter>
</activity>
<provider
@@ -2,5 +2,8 @@
include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
include ':capacitor-app'
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
include ':capacitor-browser'
project(':capacitor-browser').projectDir = new File('../node_modules/@capacitor/browser/android')
+1 -1
View File
@@ -9,7 +9,7 @@ const config: CapacitorConfig = {
CapacitorHttp: {
enabled: true
}
}
},
};
export default config;
+9
View File
@@ -9,6 +9,7 @@
"version": "0.0.1",
"dependencies": {
"@capacitor/android": "^6.0.0",
"@capacitor/app": "^6.0.0",
"@capacitor/browser": "^6.0.0",
"@capacitor/cli": "^6.0.0",
"@capacitor/core": "^6.0.0",
@@ -2002,6 +2003,14 @@
"@capacitor/core": "^6.0.0"
}
},
"node_modules/@capacitor/app": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@capacitor/app/-/app-6.0.0.tgz",
"integrity": "sha512-X5UGd90Jh5p9rmoPyMqFyFWqOypdJgVJhYcM5X1YyDVJJGzmJ5MuYv1+ajj5DW9Qyh+5a3th9WYptdGby8jidA==",
"peerDependencies": {
"@capacitor/core": "^6.0.0"
}
},
"node_modules/@capacitor/browser": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/@capacitor/browser/-/browser-6.0.0.tgz",
+2 -1
View File
@@ -37,6 +37,7 @@
"type": "module",
"dependencies": {
"@capacitor/android": "^6.0.0",
"@capacitor/app": "^6.0.0",
"@capacitor/browser": "^6.0.0",
"@capacitor/cli": "^6.0.0",
"@capacitor/core": "^6.0.0",
@@ -53,4 +54,4 @@
"svelte-persisted-store": "^0.9.2",
"vidstack": "^1.11.21"
}
}
}
+15
View File
@@ -11,6 +11,7 @@
import SyncParty from '$lib/SyncParty.svelte';
import Thumbnail from '$lib/Thumbnail.svelte';
import { bookmarkletLoadFromUrl } from '$lib/bookmarklet';
import { App } from '@capacitor/app';
import { Browser } from '@capacitor/browser';
import { Capacitor } from '@capacitor/core';
import 'beercss';
@@ -81,6 +82,20 @@
}
});
// Auth response handling for Mobile
App.addListener('appUrlOpen', (data) => {
const authUrl = new URL(data.url);
const username = authUrl.searchParams.get('username');
const token = authUrl.searchParams.get('token');
if (username && token) {
authStore.set({
username: username,
token: token
});
}
});
async function login() {
const path = new URL(`${get(instanceStore)}/authorize_token`);
const searchParams = new URLSearchParams({
@@ -5,6 +5,7 @@
import { onMount } from 'svelte';
import { authStore } from '../../store';
// Auth response handling for Desktop
onMount(() => {
authStore.set({
username: $page.url.searchParams.get('username') as string,