I have custom UI for Signup and Singing so not using AWSAuthUI
I was able to successfully setup Signup by following the documentation and am able to see confirm users in the user pool.
I am facing issue in DynamoDB Access (Authentication issue)
Bellow is the code is am using for Login
@IBAction func btn_login(_ sender: UIButton) {
ActivityIndicator.start()
if(txt_soul_id.text != "" && txt_pwd.text != ""){
let emailTextField = txt_soul_id.text!
let passwordTextField = txt_pwd.text!
let len = passwordTextField.count
if(len > 7){
if(Validations.isValidPassword(password: passwordTextField)){
let mypool = configuration.pool?.getUser(emailTextField)
mypool?.getSession(emailTextField, password: passwordTextField, validationData: nil).continueWith(block: { (task) in
if(task.error != nil){
ActivityIndicator.stop()
Alerts.normal_display(msg_title: "", msg_desc: (task.error?._userInfo!["message"])!, action_title: "OK", myVC: self)
}else{
ActivityIndicator.stop()
DispatchQueue.main.async {
let vc = self.storyboard?.instantiateViewController(withIdentifier: "EditProfileVC_sid") as! EditProfileVC
self.navigationController?.pushViewController(vc, animated: true)
}
}
return nil
})
}else{
ActivityIndicator.stop()
Alerts.normal_display(msg_title: "", msg_desc: "Password must require number, special character, uppercase and lowercase letter.", action_title: "Ok", myVC: self)
}
}else{
ActivityIndicator.stop()
Alerts.normal_display(msg_title: "Minimum 8 Character", msg_desc: "Your password must be at least 8 characters", action_title: "Ok", myVC: self)
}
}else{
ActivityIndicator.stop()
Alerts.normal_display(msg_title: "Required", msg_desc: "Username and password required", action_title: "OK", myVC: self)
}
}
Upon successful login I am trying to save into the dynamodb model I have created
@IBAction func save_profile(_ sender: UIButton) {
let dynamoDbObjectMapper = AWSDynamoDBObjectMapper.default()
// Create data object using data models you downloaded from Mobile Hub
let userItem: User = User()
var stype : [String]? = nil
stype?.append("soltype1")
userItem._userId = AWSIdentityManager.default().identityId
//userItem._soultypes = stype
userItem._about = "About Me"
userItem._bday = "19-19-1991"
userItem._culture = "Jain"
userItem._email = "abc@gmail.com"
userItem._mobile = 1234567890
userItem._mobilePrefix = "+32"
userItem._soulid = "mysid"
//Save a new item
dynamoDbObjectMapper.save(userItem, completionHandler: {
(error: Error?) -> Void in
if let error = error {
print("Amazon DynamoDB Save Error: \(error)")
return
}
print("An item was saved.")
})
}
userItem._userId is nil
Gives error nil for identityId along with Amazon DynamoDB Save Error: Error Domain=com.amazonaws.AWSCognitoIdentityErrorDomain Code=8 "(null)" UserInfo={__type=NotAuthorizedException, message=Unauthenticated access is not supported for this identity pool.}