Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit a005f59

Browse files
Add support for sending magic links to inexistent accounts (#822)
2 parents 613624e + f731cfa commit a005f59

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

Sources/WordPressKit/Services/AccountServiceRemoteREST.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ extern MagicLinkFlow const MagicLinkFlowSignup;
1717

1818
@interface AccountServiceRemoteREST : ServiceRemoteWordPressComREST <AccountServiceRemote>
1919

20+
/**
21+
* @brief Request an authentication link be sent to the email address provided.
22+
*
23+
* @param success The block that will be executed on success. Can be nil.
24+
* @param failure The block that will be executed on failure. Can be nil.
25+
*/
26+
- (void)requestWPComAuthLinkForEmail:(NSString *)email
27+
clientID:(NSString *)clientID
28+
clientSecret:(NSString *)clientSecret
29+
source:(MagicLinkSource)source
30+
wpcomScheme:(NSString *)scheme
31+
createAccountIfNotFound:(BOOL)createAccountIfNotFound
32+
success:(void (^)(void))success
33+
failure:(void (^)(NSError *error))failure;
34+
2035
/**
2136
* @brief Request an authentication link be sent to the email address provided.
2237
*

Sources/WordPressKit/Services/AccountServiceRemoteREST.m

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,19 @@ - (void)requestWPComAuthLinkForEmail:(NSString *)email
245245
clientSecret:(NSString *)clientSecret
246246
source:(MagicLinkSource)source
247247
wpcomScheme:(NSString *)scheme
248+
createAccountIfNotFound:(BOOL)createAccountIfNotFound
248249
success:(void (^)(void))success
249250
failure:(void (^)(NSError *error))failure
250251
{
251252
NSString *path = [self pathForEndpoint:@"auth/send-login-email"
252253
withVersion:WordPressComRESTAPIVersion_1_3];
253-
254+
254255
NSDictionary *extraParams = @{
255256
MagicLinkParameterFlow: MagicLinkFlowLogin,
256-
MagicLinkParameterSource: source
257+
MagicLinkParameterSource: source,
258+
@"create_account": createAccountIfNotFound ? @"true" : @"false"
257259
};
258-
260+
259261
[self requestWPComMagicLinkForEmail:email
260262
path:path
261263
clientID:clientID
@@ -266,6 +268,24 @@ - (void)requestWPComAuthLinkForEmail:(NSString *)email
266268
failure:failure];
267269
}
268270

271+
- (void)requestWPComAuthLinkForEmail:(NSString *)email
272+
clientID:(NSString *)clientID
273+
clientSecret:(NSString *)clientSecret
274+
source:(MagicLinkSource)source
275+
wpcomScheme:(NSString *)scheme
276+
success:(void (^)(void))success
277+
failure:(void (^)(NSError *error))failure
278+
{
279+
[self requestWPComAuthLinkForEmail:email
280+
clientID:clientID
281+
clientSecret:clientSecret
282+
source:source
283+
wpcomScheme:scheme
284+
createAccountIfNotFound:NO
285+
success:success
286+
failure:failure];
287+
}
288+
269289
- (void)requestWPComSignupLinkForEmail:(NSString *)email
270290
clientID:(NSString *)clientID
271291
clientSecret:(NSString *)clientSecret

0 commit comments

Comments
 (0)