mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
chore: fix windows cookie invalid characters
This commit is contained in:
parent
f2f35bd2fb
commit
7dd76d24c3
@ -47,6 +47,12 @@ import 'package:timezone/data/latest.dart' as tz;
|
|||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
Future<void> main(List<String> rawArgs) async {
|
Future<void> main(List<String> rawArgs) async {
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
if (runWebViewTitleBarWidget(rawArgs)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final arguments = await startCLI(rawArgs);
|
final arguments = await startCLI(rawArgs);
|
||||||
AppLogger.initialize(arguments["verbose"]);
|
AppLogger.initialize(arguments["verbose"]);
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ class SettingsAccountSection extends HookConsumerWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final exp = RegExp(r"https:\/\/accounts.spotify.com\/.+\/status");
|
||||||
final applicationSupportDir = await getApplicationSupportDirectory();
|
final applicationSupportDir = await getApplicationSupportDirectory();
|
||||||
final userDataFolder = Directory(
|
final userDataFolder = Directory(
|
||||||
join(applicationSupportDir.path, "webview_window_Webview2"));
|
join(applicationSupportDir.path, "webview_window_Webview2"));
|
||||||
@ -55,17 +56,22 @@ class SettingsAccountSection extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final webview = await WebviewWindow.create(
|
final webview = await WebviewWindow.create(
|
||||||
configuration:
|
configuration: CreateConfiguration(
|
||||||
CreateConfiguration(userDataFolderWindows: userDataFolder.path),
|
title: "Spotify Login",
|
||||||
|
titleBarTopPadding: kIsMacOS ? 20 : 0,
|
||||||
|
windowHeight: 720,
|
||||||
|
windowWidth: 1280,
|
||||||
|
userDataFolderWindows: userDataFolder.path,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
webview
|
||||||
webview.setOnUrlRequestCallback((url) {
|
..setBrightness(theme.colorScheme.brightness)
|
||||||
final exp = RegExp(r"https:\/\/accounts.spotify.com\/.+\/status");
|
..launch("https://accounts.spotify.com/")
|
||||||
|
..setOnUrlRequestCallback((url) {
|
||||||
if (exp.hasMatch(url)) {
|
if (exp.hasMatch(url)) {
|
||||||
webview.getAllCookies().then((cookies) async {
|
webview.getAllCookies().then((cookies) async {
|
||||||
final cookieHeader =
|
final cookieHeader =
|
||||||
"sp_dc=${cookies.firstWhere((element) => element.name == "sp_dc").value}";
|
"sp_dc=${cookies.firstWhere((element) => element.name.contains("sp_dc")).value.replaceAll("\u0000", "")}";
|
||||||
|
|
||||||
await authNotifier.login(cookieHeader);
|
await authNotifier.login(cookieHeader);
|
||||||
webview.close();
|
webview.close();
|
||||||
@ -73,12 +79,10 @@ class SettingsAccountSection extends HookConsumerWidget {
|
|||||||
context.go("/");
|
context.go("/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
webview.launch("https://accounts.spotify.com/");
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return SectionCardWithHeading(
|
return SectionCardWithHeading(
|
||||||
|
Loading…
Reference in New Issue
Block a user