File tree Expand file tree Collapse file tree 6 files changed +28
-14
lines changed
AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin
RefreshAuthorizationSession/UserPool Expand file tree Collapse file tree 6 files changed +28
-14
lines changed Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ struct RefreshUserPoolTokens: Action {
34
34
let existingTokens = existingSignedIndata. cognitoUserPoolTokens
35
35
36
36
let deviceMetadata = await DeviceMetadataHelper . getDeviceMetadata (
37
- for: environment ,
38
- with: existingSignedIndata . username )
37
+ for: existingSignedIndata . username ,
38
+ with: environment )
39
39
40
40
let asfDeviceId = try await CognitoUserPoolASF . asfDeviceID (
41
41
for: existingSignedIndata. username,
Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ struct InitiateAuthDeviceSRP: Action {
30
30
31
31
// Get device metadata
32
32
let deviceMetadata = await DeviceMetadataHelper . getDeviceMetadata (
33
- for: environment ,
34
- with: username )
33
+ for: username ,
34
+ with: environment )
35
35
36
36
let srpStateData = SRPStateData (
37
37
username: username,
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ struct InitializeSignInFlow: Action {
34
34
var deviceMetadata = DeviceMetadata . noData
35
35
if let username = signInEventData. username {
36
36
deviceMetadata = await DeviceMetadataHelper . getDeviceMetadata (
37
- for: environment ,
38
- with: username )
37
+ for: username ,
38
+ with: environment )
39
39
}
40
40
41
41
let event : SignInEvent
Original file line number Diff line number Diff line change @@ -10,12 +10,13 @@ import AWSPluginsCore
10
10
struct DeviceMetadataHelper {
11
11
12
12
static func getDeviceMetadata(
13
- for environment : Environment ,
14
- with username : String ) async -> DeviceMetadata {
13
+ for username : String ,
14
+ with environment : Environment ) async -> DeviceMetadata {
15
15
let credentialStoreClient = ( environment as? AuthEnvironment ) ? . credentialsClient
16
16
do {
17
- let data = try await credentialStoreClient? . fetchData ( type: . deviceMetadata( username: username) )
18
-
17
+ let data = try await credentialStoreClient? . fetchData (
18
+ type: . deviceMetadata( username: username)
19
+ )
19
20
if case . deviceMetadata( let fetchedMetadata, _) = data {
20
21
return fetchedMetadata
21
22
}
@@ -31,4 +32,17 @@ struct DeviceMetadataHelper {
31
32
return . noData
32
33
}
33
34
35
+ static func removeDeviceMetaData(
36
+ for username: String ,
37
+ with environment: Environment ) async {
38
+ let credentialStoreClient = ( environment as? AuthEnvironment ) ? . credentialsClient
39
+ do {
40
+ try await credentialStoreClient? . deleteData (
41
+ type: . deviceMetadata( username: username)
42
+ )
43
+ } catch {
44
+ let logger = ( environment as? LoggerProvider ) ? . logger
45
+ logger? . error ( " Unable to remove device metadata with error: \( error) " )
46
+ }
47
+ }
34
48
}
Original file line number Diff line number Diff line change @@ -62,8 +62,8 @@ class AWSAuthForgetDeviceTask: AuthForgetDeviceTask {
62
62
let userPoolService = try environment. cognitoUserPoolFactory ( )
63
63
guard let device = request. device else {
64
64
let deviceMetadata = await DeviceMetadataHelper . getDeviceMetadata (
65
- for: environment ,
66
- with: username )
65
+ for: username ,
66
+ with: environment )
67
67
if case . metadata( let data) = deviceMetadata {
68
68
let input = ForgetDeviceInput ( accessToken: accessToken, deviceKey: data. deviceKey)
69
69
_ = try await userPoolService. forgetDevice ( input: input)
Original file line number Diff line number Diff line change @@ -60,8 +60,8 @@ class AWSAuthRememberDeviceTask: AuthRememberDeviceTask {
60
60
private func rememberDevice( with accessToken: String , username: String ) async throws {
61
61
let userPoolService = try environment. cognitoUserPoolFactory ( )
62
62
let deviceMetadata = await DeviceMetadataHelper . getDeviceMetadata (
63
- for: environment ,
64
- with: username )
63
+ for: username ,
64
+ with: environment )
65
65
if case . metadata( let data) = deviceMetadata {
66
66
let input = UpdateDeviceStatusInput ( accessToken: accessToken,
67
67
deviceKey: data. deviceKey,
You can’t perform that action at this time.
0 commit comments