@@ -79,4 +79,34 @@ struct Cognito {
7979 try await req. application. cognito. authenticatable. confirmForgotPassword ( username: username, newPassword: password, confirmationCode: confirmationCode)
8080 try awsClient. syncShutdown ( )
8181 }
82+
83+ @Sendable
84+ static func confirmSignUp( req: Request , username: String , confirmationCode: String ) async throws {
85+ let awsClient = AWSClient ( httpClientProvider: . shared( req. application. http. client. shared) )
86+ let awsCognitoConfiguration = CognitoConfiguration (
87+ userPoolId: Environment . get ( " AWS_COGNITO_POOL_ID " ) !,
88+ clientId: Environment . get ( " AWS_COGNITO_CLIENT_ID " ) !,
89+ clientSecret: Environment . get ( " AWS_COGNITO_CLIENT_SECRET " ) !,
90+ cognitoIDP: CognitoIdentityProvider ( client: awsClient, region: . useast2) ,
91+ adminClient: true
92+ )
93+ req. application. cognito. authenticatable = CognitoAuthenticatable ( configuration: awsCognitoConfiguration)
94+ try await req. application. cognito. authenticatable. confirmSignUp ( username: username, confirmationCode: confirmationCode)
95+ }
96+
97+ @Sendable
98+ static func deleteUser( req: Request , accessToken: String ) async throws {
99+ let awsClient = AWSClient ( httpClientProvider: . shared( req. application. http. client. shared) )
100+ let awsCognitoConfiguration = CognitoConfiguration (
101+ userPoolId: Environment . get ( " AWS_COGNITO_POOL_ID " ) !,
102+ clientId: Environment . get ( " AWS_COGNITO_CLIENT_ID " ) !,
103+ clientSecret: Environment . get ( " AWS_COGNITO_CLIENT_SECRET " ) !,
104+ cognitoIDP: CognitoIdentityProvider ( client: awsClient, region: . useast2) ,
105+ adminClient: true
106+ )
107+ req. application. cognito. authenticatable = CognitoAuthenticatable ( configuration: awsCognitoConfiguration)
108+ let request = CognitoIdentityProvider . DeleteUserRequest ( accessToken: accessToken)
109+ try await req. application. cognito. authenticatable. configuration. cognitoIDP. deleteUser ( request)
110+ try awsClient. syncShutdown ( )
111+ }
82112}
0 commit comments