Skip to content

Commit

Permalink
Support requesting account creation when sending auth magic link (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio authored Nov 21, 2024
2 parents f591b6e + 7226ee2 commit cd53ee3
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ _None._
### New Features

- Add support for logging in into WPCOM suspended sites.
- Update `WordPressComAccountService/requestAuthenticationLink` with a new argument `createAccountIfNotFound` to allow creating new accounts. [#861]

### Bug Fixes

Expand Down
57 changes: 32 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
CFPropertyList (3.0.7)
base64
nkf
rexml
activesupport (7.1.2)
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
Expand All @@ -39,7 +43,8 @@ GEM
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
bigdecimal (3.1.5)
benchmark (0.4.0)
bigdecimal (3.1.8)
buildkit (1.5.0)
sawyer (>= 0.6)
chroma (0.2.0)
Expand All @@ -48,10 +53,10 @@ GEM
cork
nap
open4 (~> 1.3)
cocoapods (1.14.3)
cocoapods (1.16.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.3)
cocoapods-core (= 1.16.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
Expand All @@ -65,10 +70,10 @@ GEM
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
xcodeproj (>= 1.27.0, < 2.0)
cocoapods-check (1.1.0)
cocoapods (~> 1.0)
cocoapods-core (1.14.3)
cocoapods-core (1.16.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
Expand All @@ -91,7 +96,7 @@ GEM
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
concurrent-ruby (1.2.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
cork (0.3.0)
colored2 (~> 3.1)
Expand Down Expand Up @@ -137,8 +142,7 @@ GEM
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20231109)
dotenv (2.8.1)
drb (2.2.0)
ruby2_keywords
drb (2.2.1)
emoji_regex (3.2.3)
escape (0.0.4)
ethon (0.16.0)
Expand Down Expand Up @@ -232,7 +236,8 @@ GEM
rake (>= 12.3, < 14.0)
rake-compiler (~> 1.0)
xcodeproj (~> 1.22)
ffi (1.16.3)
ffi (1.17.0)
ffi (1.17.0-x86_64-darwin)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
Expand Down Expand Up @@ -281,29 +286,30 @@ GEM
http-cookie (1.0.5)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.14.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
java-properties (0.3.0)
jmespath (1.6.2)
json (2.7.1)
json (2.8.2)
jwt (2.7.1)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
language_server-protocol (3.17.0.3)
logger (1.6.1)
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.20.0)
minitest (5.25.1)
molinillo (0.8.0)
multi_json (1.15.0)
multipart-post (2.3.0)
mutex_m (0.2.0)
nanaimo (0.3.0)
nanaimo (0.4.0)
nap (1.1.0)
naturally (2.2.1)
netrc (0.11.0)
nkf (0.2.0)
no_proxy_fix (0.1.2)
nokogiri (1.15.5)
mini_portile2 (~> 2.8.2)
Expand Down Expand Up @@ -339,7 +345,7 @@ GEM
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.6)
rexml (3.3.9)
rouge (2.0.7)
rubocop (1.60.2)
json (~> 2.3)
Expand All @@ -361,6 +367,7 @@ GEM
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
securerandom (0.3.2)
security (0.1.3)
signet (0.18.0)
addressable (~> 2.8)
Expand All @@ -387,13 +394,13 @@ GEM
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
xcodeproj (1.23.0)
xcodeproj (1.27.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
nanaimo (~> 0.4.0)
rexml (>= 3.3.6, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def wordpress_authenticator_pods
## These should match the version requirement from the podspec.
pod 'Gridicons', '~> 1.0'
pod 'WordPressUI', '~> 1.7-beta'
pod 'WordPressKit', '~> 17.0'
pod 'WordPressKit', '~> 17.3'
pod 'WordPressShared', '~> 2.1-beta'

third_party_pods
Expand Down
14 changes: 7 additions & 7 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ PODS:
- Gridicons (~> 1.0)
- "NSURL+IDN (= 0.4)"
- SVProgressHUD (~> 2.2.5)
- WordPressKit (~> 17.0)
- WordPressKit (~> 17.3)
- WordPressShared (~> 2.1-beta)
- WordPressUI (~> 1.7-beta)
- WordPressKit (17.0.0):
- WordPressKit (17.3.0):
- NSObject-SafeExpectations (~> 0.0.4)
- UIDeviceIdentifier (~> 2.0)
- WordPressShared (~> 2.0-beta)
Expand All @@ -33,7 +33,7 @@ DEPENDENCIES:
- SVProgressHUD (= 2.2.5)
- SwiftLint (= 0.54.0)
- WordPressAuthenticator (from `.`)
- WordPressKit (~> 17.0)
- WordPressKit (~> 17.3)
- WordPressShared (~> 2.1-beta)
- WordPressUI (~> 1.7-beta)

Expand Down Expand Up @@ -67,12 +67,12 @@ SPEC CHECKSUMS:
SVProgressHUD: 1428aafac632c1f86f62aa4243ec12008d7a51d6
SwiftLint: c1de071d9d08c8aba837545f6254315bc900e211
UIDeviceIdentifier: 442b65b4ff1832d4ca9c2a157815cb29ad981b17
WordPressAuthenticator: d151cc7ebc1cfcbf5c28bb2c9afe760a75b49ba6
WordPressKit: a71cc550f4b525ab5eef057984c8de071462edd5
WordPressAuthenticator: 0f4f47d6f71cfa763cb636876d69170a3c710002
WordPressKit: faf8c6de7c2acfe71cf95b4db896901060967089
WordPressShared: 87f3ee89b0a3e83106106f13a8b71605fb8eb6d2
WordPressUI: a491454affda3b0fb812812e637dc5e8f8f6bd06
wpxmlrpc: 68db063041e85d186db21f674adf08d9c70627fd

PODFILE CHECKSUM: 98c48a8558a07d876e1720351adcb835bc40ce14
PODFILE CHECKSUM: 39dc5efbdeec9efbe53518c7b5dd0e7853526c1c

COCOAPODS: 1.14.3
COCOAPODS: 1.16.2
2 changes: 1 addition & 1 deletion WordPressAuthenticator.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Pod::Spec.new do |s|
# Use a loose restriction that allows both production and beta versions, up to the next major version.
# If you want to update which of these is used, specify it in the host app.
s.dependency 'WordPressUI', '~> 1.7-beta'
s.dependency 'WordPressKit', '~> 17.0'
s.dependency 'WordPressKit', '~> 17.3'
s.dependency 'WordPressShared', '~> 2.1-beta'
end
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@ public class WordPressComAccountService {

/// Requests a WordPress.com Authentication Link to be sent to the specified email address.
///
public func requestAuthenticationLink(for email: String, jetpackLogin: Bool, success: @escaping () -> Void, failure: @escaping (Error) -> Void) {
public func requestAuthenticationLink(for email: String,
jetpackLogin: Bool,
createAccountIfNotFound: Bool = false,
success: @escaping () -> Void, failure: @escaping (Error) -> Void) {
let remote = AccountServiceRemoteREST(wordPressComRestApi: anonymousAPI)

remote.requestWPComAuthLink(forEmail: email,
clientID: configuration.wpcomClientId,
clientSecret: configuration.wpcomSecret,
source: jetpackLogin ? .jetpackConnect : .default,
wpcomScheme: configuration.wpcomScheme,
createAccountIfNotFound: createAccountIfNotFound,
success: success,
failure: { error in
let result = error ?? ServiceError.unknown
Expand Down

0 comments on commit cd53ee3

Please sign in to comment.