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.

74 lines
2.0 KiB

6 years ago
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 "FIREmailLinkSignInRequest.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /** @var kEmailLinkSigninEndpoint
  19. @brief The "EmailLinkSignin" endpoint.
  20. */
  21. static NSString *const kEmailLinkSigninEndpoint = @"emailLinkSignin";
  22. /** @var kEmailKey
  23. @brief The key for the "identifier" value in the request.
  24. */
  25. static NSString *const kEmailKey = @"email";
  26. /** @var kEmailLinkKey
  27. @brief The key for the "emailLink" value in the request.
  28. */
  29. static NSString *const kOOBCodeKey = @"oobCode";
  30. /** @var kIDTokenKey
  31. @brief The key for the "IDToken" value in the request.
  32. */
  33. static NSString *const kIDTokenKey = @"idToken";
  34. /** @var kPostBodyKey
  35. @brief The key for the "postBody" value in the request.
  36. */
  37. static NSString *const kPostBodyKey = @"postBody";
  38. @implementation FIREmailLinkSignInRequest
  39. - (instancetype)initWithEmail:(NSString *)email
  40. oobCode:(NSString *)oobCode
  41. requestConfiguration:(FIRAuthRequestConfiguration *)requestConfiguration {
  42. self = [super initWithEndpoint:kEmailLinkSigninEndpoint
  43. requestConfiguration:requestConfiguration];
  44. if (self) {
  45. _email = email;
  46. _oobCode = oobCode;
  47. }
  48. return self;
  49. }
  50. - (nullable id)unencodedHTTPRequestBodyWithError:(NSError *_Nullable *_Nullable)error {
  51. NSMutableDictionary *postBody = [@{
  52. kEmailKey : _email,
  53. kOOBCodeKey : _oobCode,
  54. } mutableCopy];
  55. if (_IDToken) {
  56. postBody[kIDTokenKey] = _IDToken;
  57. }
  58. return postBody;
  59. }
  60. @end
  61. NS_ASSUME_NONNULL_END