feat(.well-known): add .well-known/immich to reference API endpoint
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -11,8 +11,10 @@ class OAuthService {
|
||||
OAuthService(this._apiService);
|
||||
|
||||
Future<OAuthConfigResponseDto?> getOAuthServerConfig(
|
||||
String serverEndpoint,
|
||||
String serverUrl,
|
||||
) async {
|
||||
// Resolve API server endpoint from user provided serverUrl
|
||||
final serverEndpoint = await _apiService.resolveEndpoint(serverUrl);
|
||||
_apiService.setEndpoint(serverEndpoint);
|
||||
|
||||
return await _apiService.oAuthApi.generateConfig(
|
||||
|
||||
@@ -38,13 +38,17 @@ class LoginForm extends HookConsumerWidget {
|
||||
var urlText = serverEndpointController.text.trim();
|
||||
|
||||
try {
|
||||
var endpointUrl = Uri.tryParse(urlText);
|
||||
var serverUrl = Uri.tryParse(urlText);
|
||||
|
||||
if (endpointUrl != null) {
|
||||
if (serverUrl != null) {
|
||||
isLoading.value = true;
|
||||
apiService.setEndpoint(endpointUrl.toString());
|
||||
final serverEndpoint =
|
||||
await apiService.resolveEndpoint(serverUrl.toString());
|
||||
apiService.setEndpoint(serverEndpoint);
|
||||
Hive.box(userInfoBox).put(serverEndpointKey, serverEndpoint);
|
||||
|
||||
var loginConfig = await apiService.oAuthApi.generateConfig(
|
||||
OAuthConfigDto(redirectUri: endpointUrl.toString()),
|
||||
OAuthConfigDto(redirectUri: serverEndpoint),
|
||||
);
|
||||
|
||||
if (loginConfig != null) {
|
||||
|
||||
Reference in New Issue
Block a user