No Description

FIRResetPasswordRequest.m 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "FIRResetPasswordRequest.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /** @var kResetPasswordEndpoint
  19. @brief The "resetPassword" endpoint.
  20. */
  21. static NSString *const kResetPasswordEndpoint = @"resetPassword";
  22. /** @var kOOBCodeKey
  23. @brief The "resetPassword" key.
  24. */
  25. static NSString *const kOOBCodeKey = @"oobCode";
  26. /** @var kCurrentPasswordKey
  27. @brief The "newPassword" key.
  28. */
  29. static NSString *const kCurrentPasswordKey = @"newPassword";
  30. @implementation FIRResetPasswordRequest
  31. - (nullable instancetype)initWithOobCode:(NSString *)oobCode
  32. newPassword:(nullable NSString *)newPassword
  33. requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
  34. self = [super initWithEndpoint:kResetPasswordEndpoint requestConfiguration:requestConfiguration];
  35. if (self) {
  36. _oobCode = oobCode;
  37. _updatedPassword = newPassword;
  38. }
  39. return self;
  40. }
  41. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  42. NSMutableDictionary *postBody = [NSMutableDictionary dictionary];
  43. postBody[kOOBCodeKey] = _oobCode;
  44. if (_updatedPassword) {
  45. postBody[kCurrentPasswordKey] = _updatedPassword;
  46. }
  47. return postBody;
  48. }
  49. @end
  50. NS_ASSUME_NONNULL_END