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.

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