[mob] Remove hardcoded url for accounts/passkey
This commit is contained in:
@@ -45,6 +45,9 @@ const supportEmail = 'support@ente.io';
|
||||
const multipartPartSize = 20 * 1024 * 1024;
|
||||
|
||||
const kDefaultProductionEndpoint = 'https://api.ente.io';
|
||||
const kAccountsUrl = 'https://accounts.ente.io';
|
||||
const kCasUrl = 'https://cas.ente.io';
|
||||
const kFamilyUrl = 'https://family.ente.io';
|
||||
|
||||
const int intMaxValue = 9223372036854775807;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import "package:flutter/cupertino.dart";
|
||||
import "package:flutter/foundation.dart";
|
||||
import "package:logging/logging.dart";
|
||||
import "package:photos/core/constants.dart";
|
||||
import "package:photos/core/network/network.dart";
|
||||
import "package:photos/utils/dialog_util.dart";
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
@@ -11,11 +11,13 @@ class PasskeyService {
|
||||
|
||||
final _enteDio = NetworkClient.instance.enteDio;
|
||||
|
||||
Future<String> getJwtToken() async {
|
||||
Future<String> getAccountsUrl() async {
|
||||
final response = await _enteDio.get(
|
||||
"/users/accounts-token",
|
||||
);
|
||||
return response.data!["accountsToken"] as String;
|
||||
final accountsUrl = response.data!["accountsUrl"] ?? kAccountsUrl;
|
||||
final jwtToken = response.data!["accountsToken"] as String;
|
||||
return "$accountsUrl/passkeys?token=$jwtToken";
|
||||
}
|
||||
|
||||
Future<bool> isPasskeyRecoveryEnabled() async {
|
||||
@@ -46,8 +48,7 @@ class PasskeyService {
|
||||
|
||||
Future<void> openPasskeyPage(BuildContext context) async {
|
||||
try {
|
||||
final jwtToken = await getJwtToken();
|
||||
final url = "$accountsUrl/passkeys?token=$jwtToken";
|
||||
final url = await getAccountsUrl();
|
||||
await launchUrlString(
|
||||
url,
|
||||
mode: LaunchMode.externalApplication,
|
||||
|
||||
@@ -399,6 +399,7 @@ class UserService {
|
||||
if (response.statusCode == 200) {
|
||||
Widget page;
|
||||
final String passkeySessionID = response.data["passkeySessionID"];
|
||||
final String accountsUrl = response.data["accountsUrl"] ?? kAccountsUrl;
|
||||
String twoFASessionID = response.data["twoFactorSessionID"];
|
||||
if (twoFASessionID.isEmpty &&
|
||||
response.data["twoFactorSessionIDV2"] != null) {
|
||||
@@ -408,6 +409,7 @@ class UserService {
|
||||
page = PasskeyPage(
|
||||
passkeySessionID,
|
||||
totp2FASessionID: twoFASessionID,
|
||||
accountsUrl: accountsUrl,
|
||||
);
|
||||
} else if (twoFASessionID.isNotEmpty) {
|
||||
await setTwoFactor(value: true);
|
||||
@@ -725,10 +727,15 @@ class UserService {
|
||||
twoFASessionID = response.data["twoFactorSessionIDV2"];
|
||||
}
|
||||
final String passkeySessionID = response.data["passkeySessionID"];
|
||||
final String accountsUrl = response.data["accountsUrl"] ?? kAccountsUrl;
|
||||
|
||||
Configuration.instance.setVolatilePassword(userPassword);
|
||||
if (passkeySessionID.isNotEmpty) {
|
||||
page = PasskeyPage(passkeySessionID, totp2FASessionID: twoFASessionID);
|
||||
page = PasskeyPage(
|
||||
passkeySessionID,
|
||||
totp2FASessionID: twoFASessionID,
|
||||
accountsUrl: accountsUrl,
|
||||
);
|
||||
} else if (twoFASessionID.isNotEmpty) {
|
||||
await setTwoFactor(value: true);
|
||||
page = TwoFactorAuthenticationPage(twoFASessionID);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import "dart:async";
|
||||
import 'dart:convert';
|
||||
|
||||
import "package:flutter/foundation.dart";
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:photos/core/configuration.dart';
|
||||
@@ -9,7 +8,6 @@ import "package:photos/core/errors.dart";
|
||||
import "package:photos/generated/l10n.dart";
|
||||
import "package:photos/l10n/l10n.dart";
|
||||
import "package:photos/models/account/two_factor.dart";
|
||||
import "package:photos/services/passkey_service.dart";
|
||||
import 'package:photos/services/user_service.dart';
|
||||
import "package:photos/ui/account/two_factor_authentication_page.dart";
|
||||
import "package:photos/ui/components/buttons/button_widget.dart";
|
||||
@@ -23,10 +21,12 @@ import 'package:url_launcher/url_launcher_string.dart';
|
||||
class PasskeyPage extends StatefulWidget {
|
||||
final String sessionID;
|
||||
final String totp2FASessionID;
|
||||
final String accountsUrl;
|
||||
|
||||
const PasskeyPage(
|
||||
this.sessionID, {
|
||||
required this.totp2FASessionID,
|
||||
required this.accountsUrl,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@@ -52,9 +52,8 @@ class _PasskeyPageState extends State<PasskeyPage> {
|
||||
}
|
||||
|
||||
Future<void> launchPasskey() async {
|
||||
final String accountsUrl = PasskeyService.instance.accountsUrl;
|
||||
await launchUrlString(
|
||||
"$accountsUrl/passkeys/verify?"
|
||||
"${widget.accountsUrl}/passkeys/verify?"
|
||||
"passkeySessionID=${widget.sessionID}"
|
||||
"&redirect=ente://passkey"
|
||||
"&clientPackage=io.ente.photos",
|
||||
|
||||
Reference in New Issue
Block a user