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

Commit 820fec8

Browse files
hichamboushabamokagio
authored andcommitted
Add support for sending magic links to inexistent accounts
1 parent 7ad99f1 commit 820fec8

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

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
@@ -244,17 +244,19 @@ - (void)requestWPComAuthLinkForEmail:(NSString *)email
244244
clientSecret:(NSString *)clientSecret
245245
source:(MagicLinkSource)source
246246
wpcomScheme:(NSString *)scheme
247+
createAccountIfNotFound:(BOOL)createAccountIfNotFound
247248
success:(void (^)(void))success
248249
failure:(void (^)(NSError *error))failure
249250
{
250251
NSString *path = [self pathForEndpoint:@"auth/send-login-email"
251252
withVersion:WordPressComRESTAPIVersion_1_3];
252-
253+
253254
NSDictionary *extraParams = @{
254255
MagicLinkParameterFlow: MagicLinkFlowLogin,
255-
MagicLinkParameterSource: source
256+
MagicLinkParameterSource: source,
257+
@"create_account": createAccountIfNotFound ? @"true" : @"false"
256258
};
257-
259+
258260
[self requestWPComMagicLinkForEmail:email
259261
path:path
260262
clientID:clientID
@@ -265,6 +267,24 @@ - (void)requestWPComAuthLinkForEmail:(NSString *)email
265267
failure:failure];
266268
}
267269

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

0 commit comments

Comments
 (0)