Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WordPressAuthenticator.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Pod::Spec.new do |s|
s.name = 'WordPressAuthenticator'
s.version = '2.2.0'
s.version = '2.2.1-beta.1'

s.summary = 'WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps.'
s.description = <<-DESC
Expand Down
4 changes: 4 additions & 0 deletions WordPressAuthenticator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
020BE74A23B0BD2E007FE54C /* WordPressAuthenticatorDisplayImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = 020BE74923B0BD2E007FE54C /* WordPressAuthenticatorDisplayImages.swift */; };
020DEF6428AA091100C85D51 /* MagicLinkRequester.swift in Sources */ = {isa = PBXBuildFile; fileRef = 020DEF6328AA091100C85D51 /* MagicLinkRequester.swift */; };
02A526CA28A3499C00FD1812 /* MagicLinkRequestedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A526C828A3499C00FD1812 /* MagicLinkRequestedViewController.swift */; };
02A526CB28A3499C00FD1812 /* MagicLinkRequestedViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 02A526C928A3499C00FD1812 /* MagicLinkRequestedViewController.xib */; };
02A526CD28A3A23900FD1812 /* UIButton+Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A526CC28A3A23900FD1812 /* UIButton+Styles.swift */; };
Expand Down Expand Up @@ -213,6 +214,7 @@

/* Begin PBXFileReference section */
020BE74923B0BD2E007FE54C /* WordPressAuthenticatorDisplayImages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressAuthenticatorDisplayImages.swift; sourceTree = "<group>"; };
020DEF6328AA091100C85D51 /* MagicLinkRequester.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MagicLinkRequester.swift; sourceTree = "<group>"; };
02A526C828A3499C00FD1812 /* MagicLinkRequestedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MagicLinkRequestedViewController.swift; sourceTree = "<group>"; };
02A526C928A3499C00FD1812 /* MagicLinkRequestedViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MagicLinkRequestedViewController.xib; sourceTree = "<group>"; };
02A526CC28A3A23900FD1812 /* UIButton+Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Styles.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -861,6 +863,7 @@
CE811D6824EDC14A00F4CCD6 /* LoginMagicLink.storyboard */,
02A526C828A3499C00FD1812 /* MagicLinkRequestedViewController.swift */,
02A526C928A3499C00FD1812 /* MagicLinkRequestedViewController.xib */,
020DEF6328AA091100C85D51 /* MagicLinkRequester.swift */,
);
path = Login;
sourceTree = "<group>";
Expand Down Expand Up @@ -1272,6 +1275,7 @@
98C9195B2308E3DA00A90E12 /* AppleAuthenticator.swift in Sources */,
B56090F9208A533200399AE4 /* WordPressAuthenticator+Events.swift in Sources */,
CEDE0D93242011E000CB3345 /* NSObject+Helpers.swift in Sources */,
020DEF6428AA091100C85D51 /* MagicLinkRequester.swift in Sources */,
020BE74A23B0BD2E007FE54C /* WordPressAuthenticatorDisplayImages.swift in Sources */,
B560913A208A563800399AE4 /* LoginLinkRequestViewController.swift in Sources */,
B560910C208A54F800399AE4 /* WordPressComOAuthClientFacade.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public class AuthenticatorAnalyticsTracker {
///
case loginWithPassword = "login_password"

/// This flow starts when the user decides to login with a password instead, with magic link logic emphasis
/// where the CTA is a secondary CTA instead of a table view row
///
case loginWithPasswordWithMagicLinkEmphasis = "login_password_magic_link_emphasis"

/// This flow starts when the user decides to log in with their site address
///
case loginWithSiteAddress = "login_site_address"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public struct WordPressAuthenticatorConfiguration {
/// If disabled, password is shown by default with an option to send a magic link.
let isWPComMagicLinkPreferredToPassword: Bool

/// If enabled, the alternative magic link action on the password screen is shown as a secondary call-to-action at the bottom.
/// If disabled, the alternative magic link action on the password screen is shown below the reset password action.
let isWPComMagicLinkShownAsSecondaryActionOnPasswordScreen: Bool

/// Designated Initializer
///
public init (wpcomClientId: String,
Expand All @@ -131,7 +135,8 @@ public struct WordPressAuthenticatorConfiguration {
continueWithSiteAddressFirst: Bool = false,
enableSiteCredentialsLoginForSelfHostedSites: Bool = false,
isWPComLoginRequiredForSiteCredentialsLogin: Bool = false,
isWPComMagicLinkPreferredToPassword: Bool = false) {
isWPComMagicLinkPreferredToPassword: Bool = false,
isWPComMagicLinkShownAsSecondaryActionOnPasswordScreen: Bool = false) {

self.wpcomClientId = wpcomClientId
self.wpcomSecret = wpcomSecret
Expand All @@ -155,5 +160,6 @@ public struct WordPressAuthenticatorConfiguration {
self.enableSiteCredentialsLoginForSelfHostedSites = enableSiteCredentialsLoginForSelfHostedSites
self.isWPComLoginRequiredForSiteCredentialsLogin = isWPComLoginRequiredForSiteCredentialsLogin
self.isWPComMagicLinkPreferredToPassword = isWPComMagicLinkPreferredToPassword
self.isWPComMagicLinkShownAsSecondaryActionOnPasswordScreen = isWPComMagicLinkShownAsSecondaryActionOnPasswordScreen
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Foundation

/// Encapsulates the async request for a magic link and email validation for use cases that send a magic link.
struct MagicLinkRequester {
/// Makes the call to request a magic authentication link be emailed to the user if possible.
func requestMagicLink(email: String, jetpackLogin: Bool) async -> Result<Void, Error> {
await withCheckedContinuation { continuation in
guard email.isValidEmail() else {
return continuation.resume(returning: .failure(MagicLinkRequestError.invalidEmail))
}

let service = WordPressComAccountService()
service.requestAuthenticationLink(for: email,
jetpackLogin: jetpackLogin,
success: {
continuation.resume(returning: .success(()))
}, failure: { error in
continuation.resume(returning: .failure(error))
})
}
}
}

extension MagicLinkRequester {
enum MagicLinkRequestError: Error {
case invalidEmail
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="aQT-Gx-U3x">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21179.7" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="aQT-Gx-U3x">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21169.4"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -20,50 +21,64 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" bounces="NO" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="KLl-Uz-wEP">
<rect key="frame" x="0.0" y="0.0" width="375" height="591"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="561"/>
<sections/>
<connections>
<outlet property="dataSource" destination="aQT-Gx-U3x" id="Sct-0G-HTk"/>
<outlet property="delegate" destination="aQT-Gx-U3x" id="2xB-Wr-Hdh"/>
</connections>
</tableView>
<view contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xwA-rd-6jO" userLabel="Button background view">
<rect key="frame" x="0.0" y="591" width="375" height="76"/>
<rect key="frame" x="0.0" y="561" width="375" height="106"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ClH-Cn-49d" userLabel="Primary Button" customClass="NUXButton" customModule="WordPressAuthenticatorResources" customModuleProvider="target">
<rect key="frame" x="16" y="16" width="343" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="iBk-Pi-8cv"/>
</constraints>
<state key="normal" title="Button"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="isPrimary" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="handleContinueButtonTapped:" destination="aQT-Gx-U3x" eventType="touchUpInside" id="Yeh-8i-cow"/>
</connections>
</button>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="RjB-bg-t6D">
<rect key="frame" x="16" y="8" width="343" height="90"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ClH-Cn-49d" userLabel="Primary Button" customClass="NUXButton" customModule="WordPressAuthenticatorResources" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="343" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="iBk-Pi-8cv"/>
</constraints>
<state key="normal" title="Button"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="isPrimary" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="handleContinueButtonTapped:" destination="aQT-Gx-U3x" eventType="touchUpInside" id="Yeh-8i-cow"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IAk-wS-Gex" customClass="NUXButton" customModule="WordPressAuthenticatorResources" customModuleProvider="target">
<rect key="frame" x="0.0" y="60" width="343" height="30"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Button"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="isPrimary" value="NO"/>
</userDefinedRuntimeAttributes>
</button>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="VfW-kE-aWC"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="bottomMargin" secondItem="ClH-Cn-49d" secondAttribute="bottom" constant="8" id="3Ba-yg-JKx"/>
<constraint firstItem="ClH-Cn-49d" firstAttribute="top" secondItem="xwA-rd-6jO" secondAttribute="topMargin" constant="8" id="GgD-0x-Aud"/>
<constraint firstItem="RjB-bg-t6D" firstAttribute="top" secondItem="xwA-rd-6jO" secondAttribute="top" constant="8" id="oia-aR-q8U"/>
<constraint firstAttribute="bottom" secondItem="RjB-bg-t6D" secondAttribute="bottom" constant="8" id="rCm-Sg-bhf"/>
</constraints>
<viewLayoutGuide key="safeArea" id="VfW-kE-aWC"/>
</view>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="xwA-rd-6jO" firstAttribute="bottom" secondItem="dFS-Ic-byk" secondAttribute="bottomMargin" constant="8" id="85d-XY-Mr8"/>
<constraint firstItem="xwA-rd-6jO" firstAttribute="trailing" secondItem="dFS-Ic-byk" secondAttribute="trailing" id="Bkw-QJ-Tbe"/>
<constraint firstItem="KLl-Uz-wEP" firstAttribute="trailing" secondItem="ClH-Cn-49d" secondAttribute="trailing" constant="16" id="Bpv-qx-bHc"/>
<constraint firstItem="ClH-Cn-49d" firstAttribute="leading" secondItem="KLl-Uz-wEP" secondAttribute="leading" constant="16" id="Rnp-SF-SGh"/>
<constraint firstItem="xwA-rd-6jO" firstAttribute="top" secondItem="KLl-Uz-wEP" secondAttribute="bottom" id="gkZ-OV-HMi"/>
<constraint firstItem="RjB-bg-t6D" firstAttribute="leading" secondItem="KLl-Uz-wEP" secondAttribute="leading" constant="16" id="kXv-Ig-Ty3"/>
<constraint firstItem="xwA-rd-6jO" firstAttribute="leading" secondItem="dFS-Ic-byk" secondAttribute="leading" id="wBE-xi-42q"/>
<constraint firstItem="KLl-Uz-wEP" firstAttribute="trailing" secondItem="RjB-bg-t6D" secondAttribute="trailing" constant="16" id="wPg-N4-vkn"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="ihD-pY-rg9"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="KLl-Uz-wEP" firstAttribute="leading" secondItem="ihD-pY-rg9" secondAttribute="leading" id="7Fn-Eh-Xx9"/>
<constraint firstItem="ihD-pY-rg9" firstAttribute="trailing" secondItem="KLl-Uz-wEP" secondAttribute="trailing" id="7MD-ux-8i0"/>
Expand All @@ -73,10 +88,10 @@
<constraint firstItem="dFS-Ic-byk" firstAttribute="leading" secondItem="ljV-kF-TaY" secondAttribute="leading" id="msS-7X-Za9"/>
<constraint firstItem="dFS-Ic-byk" firstAttribute="trailing" secondItem="ljV-kF-TaY" secondAttribute="trailing" id="zY1-Yz-kTf"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ihD-pY-rg9"/>
</view>
<connections>
<outlet property="bottomContentConstraint" destination="Dva-c1-u2U" id="Mq1-PI-MuN"/>
<outlet property="secondaryButton" destination="IAk-wS-Gex" id="psV-zJ-3Yd"/>
<outlet property="submitButton" destination="ClH-Cn-49d" id="kBa-QN-0oH"/>
<outlet property="tableView" destination="KLl-Uz-wEP" id="MGk-sG-xGv"/>
<outlet property="tableViewLeadingConstraint" destination="7Fn-Eh-Xx9" id="yKO-sE-7mh"/>
Expand All @@ -88,4 +103,9 @@
<point key="canvasLocation" x="-162.40000000000001" y="20.239880059970016"/>
</scene>
</scenes>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
Loading