Без опису

FIRVerifyPasswordRequest.m 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. NS_ASSUME_NONNULL_BEGIN
  18. /** @var kVerifyPasswordEndpoint
  19. @brief The "verifyPassword" endpoint.
  20. */
  21. static NSString *const kVerifyPasswordEndpoint = @"verifyPassword";
  22. /** @var kEmailKey
  23. @brief The key for the "email" value in the request.
  24. */
  25. static NSString *const kEmailKey = @"email";
  26. /** @var kPasswordKey
  27. @brief The key for the "password" value in the request.
  28. */
  29. static NSString *const kPasswordKey = @"password";
  30. /** @var kPendingIDTokenKey
  31. @brief The key for the "pendingIdToken" value in the request.
  32. */
  33. static NSString *const kPendingIDTokenKey = @"pendingIdToken";
  34. /** @var kCaptchaChallengeKey
  35. @brief The key for the "captchaChallenge" value in the request.
  36. */
  37. static NSString *const kCaptchaChallengeKey = @"captchaChallenge";
  38. /** @var kCaptchaResponseKey
  39. @brief The key for the "captchaResponse" value in the request.
  40. */
  41. static NSString *const kCaptchaResponseKey = @"captchaResponse";
  42. /** @var kReturnSecureTokenKey
  43. @brief The key for the "returnSecureToken" value in the request.
  44. */
  45. static NSString *const kReturnSecureTokenKey = @"returnSecureToken";
  46. @implementation FIRVerifyPasswordRequest
  47. - (nullable instancetype)initWithEmail:(NSString *)email
  48. password:(NSString *)password
  49. requestConfiguration:(nonnull FIRAuthRequestConfiguration *)requestConfiguration {
  50. self = [super initWithEndpoint:kVerifyPasswordEndpoint
  51. requestConfiguration:requestConfiguration];
  52. if (self) {
  53. _email = [email copy];
  54. _password = [password copy];
  55. _returnSecureToken = YES;
  56. }
  57. return self;
  58. }
  59. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  60. NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
  61. if (_email) {
  62. postBody[kEmailKey] = _email;
  63. }
  64. if (_password) {
  65. postBody[kPasswordKey] = _password;
  66. }
  67. if (_pendingIDToken) {
  68. postBody[kPendingIDTokenKey] = _pendingIDToken;
  69. }
  70. if (_captchaChallenge) {
  71. postBody[kCaptchaChallengeKey] = _captchaChallenge;
  72. }
  73. if (_captchaResponse) {
  74. postBody[kCaptchaResponseKey] = _captchaResponse;
  75. }
  76. if (_returnSecureToken) {
  77. postBody[kReturnSecureTokenKey] = @YES;
  78. }
  79. return postBody;
  80. }
  81. @end
  82. NS_ASSUME_NONNULL_END