Skip to content

chore(auth): sign-out state machine to use AmplifyOutputs instead of AmplifConfig types #5235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:amplify_auth_cognito_dart/src/sdk/cognito_identity_provider.dart
import 'package:amplify_auth_cognito_dart/src/state/cognito_state_machine.dart';
import 'package:amplify_auth_cognito_dart/src/state/state.dart';
import 'package:amplify_core/amplify_core.dart';
// ignore: implementation_imports
import 'package:amplify_core/src/config/amplify_outputs/auth/auth_outputs.dart';

/// {@template amplify_auth_cognito.sign_out_state_machine}
/// Manages signing out a user and clearing credentials from the local store.
Expand Down Expand Up @@ -45,8 +47,14 @@ final class SignOutStateMachine
/// The Cognito Identity Provider client.
CognitoIdentityProviderClient get _cognitoIdp => expect();

/// The Cognito user pool configuration.
CognitoUserPoolConfig get _userPoolConfig => expect();
AuthOutputs get _authOutputs {
final authOutputs = get<AuthOutputs>();
if (authOutputs?.userPoolId == null ||
authOutputs?.userPoolClientId == null) {
throw const InvalidAccountTypeException.noUserPool();
}
return authOutputs!;
}

Future<void> _onInitiate(SignOutInitiate event) async {
final options = event.options;
Expand Down Expand Up @@ -126,8 +134,9 @@ final class SignOutStateMachine
await _cognitoIdp
.revokeToken(
RevokeTokenRequest(
clientId: _userPoolConfig.appClientId,
clientSecret: _userPoolConfig.appClientSecret,
clientId: _authOutputs.userPoolClientId!,
// ignore: invalid_use_of_internal_member
clientSecret: _authOutputs.appClientSecret,
token: tokens.refreshToken,
),
)
Expand Down
Loading