You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.8 KiB

6 years ago
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FIRVerifyPasswordRequest.h"
  17. /** @var kVerifyPasswordEndpoint
  18. @brief The "verifyPassword" endpoint.
  19. */
  20. static NSString *const kVerifyPasswordEndpoint = @"verifyPassword";
  21. /** @var kEmailKey
  22. @brief The key for the "email" value in the request.
  23. */
  24. static NSString *const kEmailKey = @"email";
  25. /** @var kPasswordKey
  26. @brief The key for the "password" value in the request.
  27. */
  28. static NSString *const kPasswordKey = @"password";
  29. /** @var kPendingIDTokenKey
  30. @brief The key for the "pendingIdToken" value in the request.
  31. */
  32. static NSString *const kPendingIDTokenKey = @"pendingIdToken";
  33. /** @var kCaptchaChallengeKey
  34. @brief The key for the "captchaChallenge" value in the request.
  35. */
  36. static NSString *const kCaptchaChallengeKey = @"captchaChallenge";
  37. /** @var kCaptchaResponseKey
  38. @brief The key for the "captchaResponse" value in the request.
  39. */
  40. static NSString *const kCaptchaResponseKey = @"captchaResponse";
  41. /** @var kReturnSecureTokenKey
  42. @brief The key for the "returnSecureToken" value in the request.
  43. */
  44. static NSString *const kReturnSecureTokenKey = @"returnSecureToken";
  45. @implementation FIRVerifyPasswordRequest
  46. - (nullable instancetype)initWithEmail:(NSString *)email
  47. password:(NSString *)password
  48. requestConfiguration:(nonnull FIRAuthRequestConfiguration *)requestConfiguration {
  49. self = [super initWithEndpoint:kVerifyPasswordEndpoint
  50. requestConfiguration:requestConfiguration];
  51. if (self) {
  52. _email = [email copy];
  53. _password = [password copy];
  54. _returnSecureToken = YES;
  55. }
  56. return self;
  57. }
  58. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  59. NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
  60. if (_email) {
  61. postBody[kEmailKey] = _email;
  62. }
  63. if (_password) {
  64. postBody[kPasswordKey] = _password;
  65. }
  66. if (_pendingIDToken) {
  67. postBody[kPendingIDTokenKey] = _pendingIDToken;
  68. }
  69. if (_captchaChallenge) {
  70. postBody[kCaptchaChallengeKey] = _captchaChallenge;
  71. }
  72. if (_captchaResponse) {
  73. postBody[kCaptchaResponseKey] = _captchaResponse;
  74. }
  75. if (_returnSecureToken) {
  76. postBody[kReturnSecureTokenKey] = @YES;
  77. }
  78. return postBody;
  79. }
  80. @end