feat(.well-known): add .well-known/immich to reference API endpoint

This commit is contained in:
Connery Noble
2023-01-11 17:30:01 -08:00
parent b9b2b559a1
commit 6962df6340
14 changed files with 119 additions and 23 deletions
@@ -54,21 +54,15 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
Future<bool> login(
String email,
String password,
String serverEndpoint,
String serverUrl,
bool isSavedLoginInfo,
) async {
// Store server endpoint to Hive and test endpoint
if (serverEndpoint[serverEndpoint.length - 1] == "/") {
var validUrl = serverEndpoint.substring(0, serverEndpoint.length - 1);
Hive.box(userInfoBox).put(serverEndpointKey, validUrl);
} else {
Hive.box(userInfoBox).put(serverEndpointKey, serverEndpoint);
}
// Check Server URL validity
try {
_apiService.setEndpoint(Hive.box(userInfoBox).get(serverEndpointKey));
// Resolve API server endpoint from user provided serverUrl
final serverEndpoint = await _apiService.resolveEndpoint(serverUrl);
_apiService.setEndpoint(serverEndpoint);
await _apiService.serverInfoApi.pingServer();
Hive.box(userInfoBox).put(serverEndpointKey, serverEndpoint);
} catch (e) {
debugPrint('Invalid Server Endpoint Url $e');
return false;
@@ -90,7 +84,7 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
return setSuccessLoginInfo(
accessToken: loginResponse.accessToken,
serverUrl: serverEndpoint,
serverUrl: serverUrl,
isSavedLoginInfo: isSavedLoginInfo,
);
} catch (e) {
@@ -174,7 +168,6 @@ class AuthenticationNotifier extends StateNotifier<AuthenticationState> {
var deviceInfo = await _deviceInfoService.getDeviceInfo();
userInfoHiveBox.put(deviceIdKey, deviceInfo["deviceId"]);
userInfoHiveBox.put(accessTokenKey, accessToken);
userInfoHiveBox.put(serverEndpointKey, serverUrl);
state = state.copyWith(
isAuthenticated: true,