Advertisement
Guest User

Untitled

a guest
Jun 13th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. // The SDK is initialized as shared instance so can be accessed
  2. // from multiple View Controllers
  3. let sdkNoUser:AcceptSDK = AcceptSDK.sharedInstance()
  4.  
  5. // Set the SDK target environment - in this case Public Test
  6. // for remind username and reset password the SDK does not need to be authenticated
  7. sdkNoUser.setup(with: AcceptEnvironment.publicTest,
  8. username: nil,
  9. password: nil)
  10.  
  11. //End of credential management process
  12. let completion:CredentialManagementCompletion = {(result:WDAcceptResult?, error:Error?) in
  13. //result - details from the credential management process
  14. // AcceptResultStatusOK indicates the process ended with OK status
  15. // AcceptResultStatusPasswordCriteriaNotMet - in the case of changing the password indicates that the new password does not
  16. // meet the criteria
  17. // AcceptResultStatusPasswordValidationFailure - in the case of changing password indicates the password validation failure
  18. // old and new password mismatch
  19. }
  20.  
  21. //******************* PASSWORD POLICY *******************//
  22. //End of password policy process
  23. let policyCompletion:PasswordPolicyCompletion = {(policy:WDPasswordPolicyResult? , error:Error?) in
  24. //policy - the details of the password policy
  25. }
  26.  
  27. //Obtain the password policy valid for the user credentials on this system
  28. sdkNoUser.userManager.passwordPolicy(policyCompletion)
  29.  
  30. //******************* REMIND USERNAME *******************//
  31. //Remind username
  32. let remindUserName:WDAcceptRemindUsername = WDAcceptRemindUsername()
  33. remindUserName.email = "User@Email" // email address to send the remind message to
  34.  
  35. // Remind username - the message will be sent to specified email address
  36. sdkNoUser.userManager.manageCredentials(remindUserName, // Remind username object
  37. completion:completion) // End of credential management process
  38.  
  39.  
  40. //******************* RESET PASSWORD *******************//
  41. let resetPassword:WDAcceptRequestPasswordReset = WDAcceptRequestPasswordReset()
  42. resetPassword.username = "UserName" // username for which to reset the password
  43.  
  44. //Reset password - instructions will be sent to the specified user email address (as stored on the backend)
  45. sdkNoUser.userManager.manageCredentials(resetPassword, // Reset password object
  46. completion:completion) // End of credential management process
  47.  
  48. //******************* CHANGE PASSWORD *******************//
  49. // Change Password details - available only to the AUTHENTICATED user
  50. let changePassword:WDAcceptChangePassword = WDAcceptChangePassword()
  51. changePassword.currentPassword = "Old Password" // old password of the current user
  52. changePassword.setNewPassword = "New Password" // new password of the current user
  53.  
  54. // Change password for the currently logged in user
  55. sdk.userManager.manageCredentials(changePassword, // Change password object
  56. completion:completion)//End of credential management process
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement