AbandonedCheckoutProtocolController.php
2 years ago
AbandonedCheckoutsController.php
3 years ago
AccountController.php
2 years ago
ActivationsController.php
3 years ago
AffiliationProductsController.php
2 years ago
AffiliationProtocolController.php
2 years ago
AffiliationRequestsController.php
2 years ago
AffiliationsController.php
2 years ago
AutoFeeProtocolController.php
5 months ago
AutoFeesController.php
5 months ago
BalanceTransactionsController.php
3 years ago
BrandController.php
3 months ago
BumpsController.php
3 years ago
CancellationActsController.php
3 years ago
CancellationReasonsController.php
3 years ago
ChargesController.php
2 years ago
CheckEmailController.php
11 months ago
CheckoutsController.php
5 months ago
ClicksController.php
2 years ago
CouponsController.php
3 years ago
CustomerController.php
3 weeks ago
CustomerNotificationProtocolController.php
2 years ago
CustomerPortalProtocolController.php
1 year ago
DisplayCurrencyController.php
1 year ago
DisputesController.php
9 months ago
DownloadsController.php
3 years ago
DraftCheckoutsController.php
2 years ago
ExportsController.php
2 years ago
FulfillmentsController.php
3 years ago
ImportRowsController.php
1 month ago
IncomingWebhooksController.php
2 months ago
IntegrationCatalogController.php
1 year ago
IntegrationProvidersController.php
3 years ago
IntegrationsController.php
2 months ago
InvoicesController.php
1 year ago
LicensesController.php
3 years ago
LineItemsController.php
1 year ago
LoginController.php
3 weeks ago
ManualPaymentMethodsController.php
3 years ago
MediasController.php
3 years ago
OrderController.php
1 year ago
OrderProtocolController.php
2 years ago
ParcelTemplateController.php
3 months ago
PaymentIntentsController.php
2 years ago
PaymentMethodsController.php
2 years ago
PayoutGroupsController.php
2 years ago
PayoutsController.php
2 years ago
PeriodsController.php
3 years ago
PricesController.php
11 months ago
ProcessorController.php
3 years ago
ProductCollectionsController.php
2 years ago
ProductGroupsController.php
3 years ago
ProductMediaController.php
1 year ago
ProductsController.php
1 month ago
PromotionsController.php
3 years ago
ProvisionalAccountController.php
3 years ago
PurchasesController.php
3 years ago
ReferralItemsController.php
2 years ago
ReferralsController.php
2 years ago
RefundsController.php
3 years ago
RegisteredWebhookController.php
2 years ago
RestController.php
1 year ago
ReturnItemsController.php
2 years ago
ReturnReasonsController.php
2 years ago
ReturnRequestsController.php
2 years ago
ReviewProtocolController.php
4 months ago
ReviewsController.php
4 months ago
RuleSchemaController.php
5 months ago
SettingsController.php
3 weeks ago
ShippingMethodController.php
3 years ago
ShippingProfileController.php
3 years ago
ShippingProtocolController.php
3 years ago
ShippingRateController.php
3 years ago
ShippingZoneController.php
3 years ago
StatisticsController.php
2 years ago
SubscriptionProtocolController.php
2 years ago
SubscriptionsController.php
2 years ago
SwapsController.php
1 year ago
TaxOverrideController.php
2 years ago
TaxProtocolController.php
2 years ago
TaxRegistrationController.php
3 years ago
TaxZoneController.php
3 years ago
UploadsController.php
3 years ago
UpsellFunnelsController.php
2 years ago
UpsellsController.php
2 years ago
VariantOptionsController.php
2 years ago
VariantValuesController.php
2 years ago
VariantsController.php
2 years ago
VerificationCodeController.php
3 weeks ago
WebhookController.php
3 years ago
CheckEmailController.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Controllers\Rest; |
| 4 | |
| 5 | /** |
| 6 | * Handle check email requests through the REST API |
| 7 | */ |
| 8 | class CheckEmailController extends RestController { |
| 9 | /** |
| 10 | * Check login. |
| 11 | * |
| 12 | * @param \WP_REST_Request $request The REST request. |
| 13 | * |
| 14 | * @return true|\WP_Error |
| 15 | */ |
| 16 | public function checkEmail( \WP_REST_Request $request ) { |
| 17 | $login = $request->get_param( 'login' ) ?? ''; |
| 18 | // handle email. |
| 19 | if ( strpos( $login, '@' ) !== false ) { |
| 20 | $user = get_user_by( 'email', $login ); |
| 21 | return $user ? true : new \WP_Error( |
| 22 | 'invalid_email', |
| 23 | __( 'There is no account with that username or email address.', 'surecart' ) |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | // check for login. |
| 28 | $user = get_user_by( 'login', $login ); |
| 29 | |
| 30 | return $user ? true : new \WP_Error( |
| 31 | 'invalid_username', |
| 32 | sprintf( |
| 33 | /* translators: %s: User name. */ |
| 34 | __( 'The username <strong>%s</strong> is not registered on this site. If you are unsure of your username, try your email address instead.', 'surecart' ), |
| 35 | esc_html( $login ) |
| 36 | ) |
| 37 | ); |
| 38 | } |
| 39 | } |
| 40 |