Skip to content

Commit 5299785

Browse files
ameterpalpatimroyjit
authored
feat (auth): add deleteUser API (#1582)
Co-authored-by: Tim Schmelter <[email protected]> Co-authored-by: Jithin Roy <[email protected]>
1 parent 393102d commit 5299785

24 files changed

+853
-120
lines changed

Amplify.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@
268268
5C09CCC326D0733700CDCA9F /* GeoCategoryConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C09CCC126D0733700CDCA9F /* GeoCategoryConfigurationTests.swift */; };
269269
5C09CCC526D074B100CDCA9F /* MockGeoCategoryPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C09CCC426D074B100CDCA9F /* MockGeoCategoryPlugin.swift */; };
270270
5C2D791526F5172E00420798 /* Geo+Country.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C2D791426F5172E00420798 /* Geo+Country.swift */; };
271+
5C3324912772BCF700F2C47B /* AuthDeleteUserOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C3324902772BCF700F2C47B /* AuthDeleteUserOperation.swift */; };
272+
5C3324932772BD3D00F2C47B /* AuthDeleteUserRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C3324922772BD3D00F2C47B /* AuthDeleteUserRequest.swift */; };
271273
5C763DA026F2CAF5006650E7 /* Geo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C763D9F26F2CAF5006650E7 /* Geo.swift */; };
272274
5C763DA226F2CB6A006650E7 /* Geo+Coordinates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C763DA126F2CB6A006650E7 /* Geo+Coordinates.swift */; };
273275
5C763DA426F2CCDF006650E7 /* CLocationCoordinate2D+Geo.Coordinates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C763DA326F2CCDF006650E7 /* CLocationCoordinate2D+Geo.Coordinates.swift */; };
@@ -1180,6 +1182,8 @@
11801182
5C09CCC126D0733700CDCA9F /* GeoCategoryConfigurationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeoCategoryConfigurationTests.swift; sourceTree = "<group>"; };
11811183
5C09CCC426D074B100CDCA9F /* MockGeoCategoryPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockGeoCategoryPlugin.swift; sourceTree = "<group>"; };
11821184
5C2D791426F5172E00420798 /* Geo+Country.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Geo+Country.swift"; sourceTree = "<group>"; };
1185+
5C3324902772BCF700F2C47B /* AuthDeleteUserOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthDeleteUserOperation.swift; sourceTree = "<group>"; };
1186+
5C3324922772BD3D00F2C47B /* AuthDeleteUserRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthDeleteUserRequest.swift; sourceTree = "<group>"; };
11831187
5C763D9F26F2CAF5006650E7 /* Geo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Geo.swift; sourceTree = "<group>"; };
11841188
5C763DA126F2CB6A006650E7 /* Geo+Coordinates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Geo+Coordinates.swift"; sourceTree = "<group>"; };
11851189
5C763DA326F2CCDF006650E7 /* CLocationCoordinate2D+Geo.Coordinates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CLocationCoordinate2D+Geo.Coordinates.swift"; sourceTree = "<group>"; };
@@ -2863,6 +2867,7 @@
28632867
B4251A04242503F6007F59EF /* AuthConfirmResetPasswordOperation.swift */,
28642868
B473B53D245DE8E100C45C72 /* AuthConfirmSignInOperation.swift */,
28652869
B450740C2411553D0098F02D /* AuthConfirmSignUpOperation.swift */,
2870+
5C3324902772BCF700F2C47B /* AuthDeleteUserOperation.swift */,
28662871
B46884112460A8D600221268 /* AuthFetchDevicesOperation.swift */,
28672872
B4FA76042416E0F0006F59CE /* AuthFetchSessionOperation.swift */,
28682873
B46884132460A8E000221268 /* AuthForgetDeviceOperation.swift */,
@@ -2917,6 +2922,7 @@
29172922
B473B53F245DE93100C45C72 /* AuthConfirmSignInRequest.swift */,
29182923
B43CD8532411469D00BF5A60 /* AuthConfirmSignUpRequest.swift */,
29192924
B4B5CC8A2457B32D0019C783 /* AuthConfirmUserAttributeRequest.swift */,
2925+
5C3324922772BD3D00F2C47B /* AuthDeleteUserRequest.swift */,
29202926
B46884172460A92900221268 /* AuthFetchDevicesRequest.swift */,
29212927
B4FA76062416E82B006F59CE /* AuthFetchSessionRequest.swift */,
29222928
B4B5CC802457B0690019C783 /* AuthFetchUserAttributesRequest.swift */,
@@ -5111,6 +5117,7 @@
51115117
FAAFAF37239051E6002CF932 /* AtomicDictionary.swift in Sources */,
51125118
95DAAB2F237E63370028544F /* LanguageType.swift in Sources */,
51135119
B4D3852E236C97360014653D /* PredictionsIdentifyOperation.swift in Sources */,
5120+
5C3324932772BD3D00F2C47B /* AuthDeleteUserRequest.swift in Sources */,
51145121
FA09B9412321BB78000E064D /* JSONValue.swift in Sources */,
51155122
B9A6A4E024452E0D00AC2792 /* AccessLevel.swift in Sources */,
51165123
95DAAB2E237E63370028544F /* AgeRange.swift in Sources */,
@@ -5320,6 +5327,7 @@
53205327
B4507419241166580098F02D /* AuthSession.swift in Sources */,
53215328
B99EF4B723DB072000D821BC /* Temporal+Hashable.swift in Sources */,
53225329
B92E03B92367CE7A006CEB8D /* Model+Schema.swift in Sources */,
5330+
5C3324912772BCF700F2C47B /* AuthDeleteUserOperation.swift in Sources */,
53235331
FA58456724D9D6960028D65A /* AmplifyOperation+APIPublishers.swift in Sources */,
53245332
950A26DB23D15D7E00D92B19 /* PredictionsTranslateTextOperation.swift in Sources */,
53255333
B46884162460A8ED00221268 /* AuthRememberDeviceOperation.swift in Sources */,

Amplify/Categories/Auth/AuthCategory+ClientBehavior.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ extension AuthCategory: AuthCategoryBehavior {
8888
plugin.signOut(options: options, listener: listener)
8989
}
9090

91+
@discardableResult
92+
public func deleteUser(listener: AuthDeleteUserOperation.ResultListener?) -> AuthDeleteUserOperation {
93+
plugin.deleteUser(listener: listener)
94+
}
95+
9196
@discardableResult
9297
public func fetchAuthSession(options: AuthFetchSessionOperation.Request.Options? = nil,
9398
listener: AuthFetchSessionOperation.ResultListener?) -> AuthFetchSessionOperation {

Amplify/Categories/Auth/AuthCategoryBehavior+Combine.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ public extension AuthCategoryBehavior {
137137
signOut(options: options, listener: nil)
138138
}
139139

140+
/// Delete the account of the currently logged-in user.
141+
///
142+
/// - Returns: AuthDeleteUserOperation
143+
@discardableResult
144+
func deleteUser() -> AuthDeleteUserOperation {
145+
deleteUser(listener: nil)
146+
}
147+
140148
/// Fetch the current authentication session.
141149
///
142150
/// - Parameters:

Amplify/Categories/Auth/AuthCategoryBehavior.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
124124
func signOut(options: AuthSignOutOperation.Request.Options?,
125125
listener: AuthSignOutOperation.ResultListener?) -> AuthSignOutOperation
126126

127+
/// Delete the account of the currently logged-in user.
128+
///
129+
/// - Parameters:
130+
/// - listener: Triggered when the operation completes.
131+
/// - Returns: AuthDeleteUserOperation
132+
@discardableResult
133+
func deleteUser(listener: AuthDeleteUserOperation.ResultListener?) -> AuthDeleteUserOperation
134+
127135
/// Fetch the current authentication session.
128136
///
129137
/// - Parameters:

Amplify/Categories/Auth/Models/AuthEventName.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public extension HubPayload.EventName.Auth {
1515
/// eventName emitted when a user is signedOut from Auth category
1616
static let signedOut = "Auth.signedOut"
1717

18+
/// eventName emitted when a user is deleted from Auth category
19+
static let userDeleted = "Auth.userDeleted"
20+
1821
/// eventName emitted when the current session has expired
1922
static let sessionExpired = "Auth.sessionExpired"
2023
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Foundation
9+
10+
public protocol AuthDeleteUserOperation: AmplifyOperation<
11+
AuthDeleteUserRequest,
12+
Void,
13+
AuthError
14+
> {}
15+
16+
public extension HubPayload.EventName.Auth {
17+
18+
/// eventName for HubPayloads emitted by this operation
19+
static let deleteUserAPI = "Auth.deleteUserAPI"
20+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
import Foundation
9+
10+
/// Request for delete user
11+
public struct AuthDeleteUserRequest: AmplifyOperationRequest {
12+
13+
/// Options is unused for AuthDeleteUserRequest. It is included for conformance
14+
/// with the AmplifyOperationRequest protocol.
15+
public var options = Options()
16+
17+
public init() {}
18+
}
19+
20+
public extension AuthDeleteUserRequest {
21+
struct Options {}
22+
}
23+

0 commit comments

Comments
 (0)