-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(amplify_auth_cognito): resendSignUpCode (#23)
- Loading branch information
1 parent
3fb4e1d
commit 5e9509e
Showing
21 changed files
with
421 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...kotlin/com/amazonaws/amplify/amplify_auth_cognito/types/FlutterResendSignUpCodeRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazonaws.amplify.amplify_auth_cognito.types | ||
|
||
data class FlutterResendSignUpCodeRequest(val map: HashMap<String, *>) { | ||
val username: String = map["username"] as String; | ||
val options: HashMap<String, *>? = map["options"] as HashMap<String, *>?; | ||
|
||
companion object { | ||
fun validate(req : HashMap<String, *>?): Boolean { | ||
var valid: Boolean = true; | ||
if (req != null) { | ||
if (!req.containsKey("username") && req["username"] != "") { | ||
valid = false; | ||
} | ||
} | ||
return valid; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/amplify_auth_cognito/ios/Classes/FlutterResendSignUpCodeRequest.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
struct FlutterResendSignUpCodeRequest { | ||
var username: String | ||
init(dict: NSMutableDictionary){ | ||
self.username = dict["username"] as! String | ||
} | ||
static func validate(dict: NSMutableDictionary) -> Bool { | ||
var valid: Bool = true; | ||
if (dict["username"] == nil) { | ||
valid = false; | ||
} | ||
return valid; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
packages/amplify_auth_cognito/ios/Classes/FlutterResendSignUpCodeResult.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
import Flutter | ||
import Foundation | ||
import Amplify | ||
|
||
struct FlutterResendSignUpCodeResult { | ||
var codeDeliveryDetails: [String: String] | ||
|
||
init(res: AmplifyOperation<AuthResendSignUpCodeRequest, AuthCodeDeliveryDetails, AuthError>.OperationResult){ | ||
self.codeDeliveryDetails = setCodeDeliveryDetails(res: res) | ||
} | ||
|
||
func toJSON() -> Dictionary<String, Any> { | ||
return ["codeDeliveryDetails": self.codeDeliveryDetails] | ||
} | ||
} | ||
|
||
|
||
func setCodeDeliveryDetails(res: AmplifyOperation<AuthResendSignUpCodeRequest, AuthCodeDeliveryDetails, AuthError>.OperationResult) -> [String: String] { | ||
var deliveryMap: [String: String] = [:] | ||
switch res { | ||
case .success(let codeDeliveryDetails): | ||
if case let .email(e) = codeDeliveryDetails.destination { | ||
deliveryMap["destination"] = e! as String | ||
deliveryMap["attributeName"] = "email" | ||
deliveryMap["deliveryMedium"] = "EMAIL" | ||
} | ||
|
||
if case let .phone(e) = codeDeliveryDetails.destination { | ||
deliveryMap["destination"] = e! as String | ||
deliveryMap["attributeName"] = "phone" | ||
} | ||
|
||
if case let .sms(e) = codeDeliveryDetails.destination { | ||
deliveryMap["destination"] = e! as String | ||
deliveryMap["attributeName"] = "sms" | ||
deliveryMap["deliveryMedium"] = "SMS" | ||
} | ||
|
||
if case let .unknown(e) = codeDeliveryDetails.destination { | ||
deliveryMap["destination"] = e! as String | ||
deliveryMap["attributeName"] = "unknown" | ||
} | ||
case .failure: | ||
deliveryMap = [:] | ||
} | ||
return deliveryMap | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.