0 ? 'index.php?plan=' . $plan : 'account.php')); exit; }; if (currentCustomer($context) !== null) { $afterLogin(); } $pending = $_SESSION['shop_login']['email'] ?? null; $message = $_SESSION['shop_login']['message'] ?? null; unset($_SESSION['shop_login']['message']); $back = static function (?array $msg = null): never { $_SESSION['shop_login']['message'] = $msg; header('Location: login.php'); exit; }; if ($_SERVER['REQUEST_METHOD'] === 'POST') { verifyShopCsrf(); $action = (string) ($_POST['action'] ?? ''); $verification = new ShopVerification(); if ($action === 'restart') { unset($_SESSION['shop_login']['email']); $back(); } if ($action === 'send' || $action === 'resend') { $email = $action === 'resend' ? (string) $pending : ShopCustomers::normaliseEmail((string) ($_POST['email'] ?? '')); if (!filter_var($email, FILTER_VALIDATE_EMAIL) || strlen($email) > 191) { $back(['error', 'Please enter a valid email address.']); } $result = $verification->send($resellerId, $shopName, $email, ShopVerification::LOGIN, clientIp(), (new ShopEmailSettings())->replyTo($resellerId)); $_SESSION['shop_login']['email'] = $email; $back(match ($result) { 'sent' => ['ok', "We’ve sent a 6-digit code to $email. It can take a minute to arrive — check your spam folder too."], 'limited' => ['error', 'A code was sent recently. Please wait a minute, then use “Send a new code”.'], default => ['error', 'We couldn’t send the email just now. Please try again shortly.'], }); } if ($action === 'verify' && $pending !== null) { $result = $verification->verify($resellerId, (string) $pending, ShopVerification::LOGIN, (string) ($_POST['code'] ?? '')); if ($result !== 'ok') { $back(['error', match ($result) { 'expired' => 'That code has expired. Use “Send a new code”.', 'locked' => 'Too many incorrect attempts. Use “Send a new code”.', default => 'That code isn’t right. Use the code from the most recent email.', }]); } $customers = new ShopCustomers(); $customer = $customers->findOrCreate($resellerId, (string) $pending); if ($customer['status'] !== 'active') { unset($_SESSION['shop_login']['email']); $back(['error', 'This account can’t log in. Please contact the shop.']); } $plan = $_SESSION['shop_login']['plan'] ?? null; loginCustomer($customer); $_SESSION['shop_login']['plan'] = $plan; $customers->touchLogin((int) $customer['id']); $customers->claimAccounts($customer, (string) $context['reseller']['email_address']); $afterLogin(); } $back(); } $input = 'w-full rounded-xl border border-white/10 bg-white/5 px-4 py-2.5 text-sm text-white placeholder-slate-500 outline-none focus:border-indigo-400'; $primary = 'w-full rounded-xl bg-gradient-to-r from-indigo-500 to-violet-600 py-2.5 text-sm font-semibold text-white hover:opacity-90'; ?>
= e($shopName) ?>
Enter your email and we’ll send you a 6-digit code. No password needed — new here? The same code creates your account.
Enter the 6-digit code we sent to = e((string) $pending) ?>.