feat(mobile): Add support for Basic Authentication (#6840)

This commit is contained in:
rovo89 2024-02-04 21:35:13 +01:00 committed by GitHub
parent b4c211cad1
commit 5061c35c8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 33 additions and 33 deletions

View file

@ -1,3 +1,5 @@
import 'dart:convert';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
@ -106,6 +108,10 @@ class WebsocketNotifier extends StateNotifier<WebsocketState> {
final accessToken = Store.get(StoreKey.accessToken);
try {
final endpoint = Uri.parse(Store.get(StoreKey.serverEndpoint));
final headers = {"x-immich-user-token": accessToken};
if (endpoint.userInfo.isNotEmpty) {
headers["Authorization"] = "Basic ${base64.encode(utf8.encode(endpoint.userInfo))}";
}
debugPrint("Attempting to connect to websocket");
// Configure socket transports must be specified
@ -118,7 +124,7 @@ class WebsocketNotifier extends StateNotifier<WebsocketState> {
.enableForceNew()
.enableForceNewConnection()
.enableAutoConnect()
.setExtraHeaders({"Authorization": "Bearer $accessToken"})
.setExtraHeaders(headers)
.build(),
);