Rewired login confirmation
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
Some checks failed
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/chain_gateway Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
ci/woodpecker/push/bump_version Pipeline failed
This commit is contained in:
@@ -8,13 +8,10 @@ import 'package:pshared/api/requests/login_data.dart';
|
||||
import 'package:pshared/api/requests/password/change.dart';
|
||||
import 'package:pshared/api/requests/password/forgot.dart';
|
||||
import 'package:pshared/api/requests/password/reset.dart';
|
||||
import 'package:pshared/api/responses/login.dart';
|
||||
import 'package:pshared/data/mapper/account/account.dart';
|
||||
import 'package:pshared/models/account/account.dart';
|
||||
import 'package:pshared/models/auth/login_outcome.dart';
|
||||
import 'package:pshared/models/auth/pending_login.dart';
|
||||
import 'package:pshared/service/authorization/service.dart';
|
||||
import 'package:pshared/service/authorization/storage.dart';
|
||||
import 'package:pshared/service/files.dart';
|
||||
import 'package:pshared/service/services.dart';
|
||||
import 'package:pshared/utils/http/requests.dart';
|
||||
@@ -29,41 +26,6 @@ class AccountService {
|
||||
return AuthorizationService.login(_objectType, login);
|
||||
}
|
||||
|
||||
static Future<void> resendLoginCode(PendingLogin pending, {String? destination}) async {
|
||||
await getPOSTResponse(
|
||||
_objectType,
|
||||
'confirmations/resend',
|
||||
{
|
||||
'target': 'login',
|
||||
if (destination != null) 'destination': destination,
|
||||
},
|
||||
authToken: pending.pendingToken.token,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<Account> confirmLoginCode({
|
||||
required PendingLogin pending,
|
||||
required String code,
|
||||
String? destination,
|
||||
}) async {
|
||||
final response = await getPOSTResponse(
|
||||
_objectType,
|
||||
'confirmations/verify',
|
||||
{
|
||||
'target': 'login',
|
||||
'code': code,
|
||||
if (destination != null) 'destination': destination,
|
||||
'sessionIdentifier': pending.session.toJson(),
|
||||
},
|
||||
authToken: pending.pendingToken.token,
|
||||
);
|
||||
|
||||
final loginResponse = LoginResponse.fromJson(response);
|
||||
await AuthorizationStorage.updateToken(loginResponse.accessToken);
|
||||
await AuthorizationStorage.updateRefreshToken(loginResponse.refreshToken);
|
||||
return loginResponse.account.toDomain();
|
||||
}
|
||||
|
||||
static Future<Account> restore() async {
|
||||
return AuthorizationService.restore();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Services {
|
||||
static const String account = 'accounts';
|
||||
static const String authorization = 'authorization';
|
||||
static const String comments = 'comments';
|
||||
static const String confirmations = 'confirmations';
|
||||
static const String device = 'device';
|
||||
static const String invitations = 'invitations';
|
||||
static const String organization = 'organizations';
|
||||
|
||||
60
frontend/pshared/lib/service/verification.dart
Normal file
60
frontend/pshared/lib/service/verification.dart
Normal file
@@ -0,0 +1,60 @@
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import 'package:pshared/api/requests/confirmations/login_confirmation.dart';
|
||||
import 'package:pshared/api/responses/login.dart';
|
||||
import 'package:pshared/data/mapper/session_identifier.dart';
|
||||
import 'package:pshared/models/account/account.dart';
|
||||
import 'package:pshared/data/mapper/account/account.dart';
|
||||
import 'package:pshared/models/auth/pending_login.dart';
|
||||
import 'package:pshared/service/authorization/storage.dart';
|
||||
import 'package:pshared/service/services.dart';
|
||||
import 'package:pshared/utils/http/requests.dart';
|
||||
|
||||
|
||||
class VerificationService {
|
||||
static final _logger = Logger('service.verification');
|
||||
static const String _objectType = Services.account;
|
||||
|
||||
static Future<void> requestLoginCode(PendingLogin pending, {String? destination}) async {
|
||||
_logger.fine('Requesting login confirmation code');
|
||||
await getPOSTResponse(
|
||||
_objectType,
|
||||
'',
|
||||
LoginConfirmationRequest(destination: destination).toJson(),
|
||||
authToken: pending.pendingToken.token,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> resendLoginCode(PendingLogin pending, {String? destination}) async {
|
||||
_logger.fine('Resending login confirmation code');
|
||||
await getPOSTResponse(
|
||||
_objectType,
|
||||
'/resend',
|
||||
LoginConfirmationRequest(destination: destination).toJson(),
|
||||
authToken: pending.pendingToken.token,
|
||||
);
|
||||
}
|
||||
|
||||
static Future<Account> confirmLoginCode({
|
||||
required PendingLogin pending,
|
||||
required String code,
|
||||
String? destination,
|
||||
}) async {
|
||||
_logger.fine('Confirming login code');
|
||||
final response = await getPOSTResponse(
|
||||
_objectType,
|
||||
'/verify',
|
||||
LoginConfirmationVerifyRequest(
|
||||
code: code,
|
||||
destination: destination,
|
||||
sessionIdentifier: pending.session.toDTO(),
|
||||
).toJson(),
|
||||
authToken: pending.pendingToken.token,
|
||||
);
|
||||
|
||||
final loginResponse = LoginResponse.fromJson(response);
|
||||
await AuthorizationStorage.updateToken(loginResponse.accessToken);
|
||||
await AuthorizationStorage.updateRefreshToken(loginResponse.refreshToken);
|
||||
return loginResponse.account.toDomain();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user