fix registration
This commit is contained in:
@@ -173,16 +173,16 @@ try {
|
||||
. rtrim($server_url, '/');
|
||||
$verify_url = $base_url . '/login/verify.php?token=' . $token;
|
||||
|
||||
// ── Step 14: Send verification email via system SMTP ─────────────────────
|
||||
// Uses $SMTP from config.php (system-level, not company SMTP) because the
|
||||
// user does not have a company yet at registration time.
|
||||
// If the mailer fails it exits internally with its own error JSON response.
|
||||
// ── Step 14: Send verification email (non-fatal) ─────────────────────────
|
||||
// silent=true means the mailer returns false on failure instead of calling
|
||||
// exit() — so the account is always created even if SMTP is unavailable.
|
||||
require_once $include_url . 'assets/utils/module/mailer.php';
|
||||
|
||||
$mailer = new mailer(['pdo1' => $pdo1]);
|
||||
$mailer->send_email([
|
||||
$mailer = new mailer(['pdo1' => $pdo1]);
|
||||
$mail_sent = $mailer->send_email([
|
||||
'company_id' => 0,
|
||||
'smtp' => $SMTP,
|
||||
'silent' => true,
|
||||
'to' => $email,
|
||||
'subject' => 'Verify your email — WMS',
|
||||
'message' => implode("\n", [
|
||||
@@ -205,7 +205,15 @@ try {
|
||||
|
||||
// ── Step 15: Respond ──────────────────────────────────────────────────────
|
||||
$answer['success'] = 1;
|
||||
$answer['message'] = 'Account created! Please check your email to verify your account.';
|
||||
if ($mail_sent) {
|
||||
$answer['message'] = 'Account created! Please check your email to verify your account.';
|
||||
} else {
|
||||
// Email failed (e.g. SMTP blocked on this server) — account still created.
|
||||
// Return the verify URL so an admin can share it manually, and tell the
|
||||
// user to contact their administrator.
|
||||
$answer['message'] = 'Account created! However, the verification email could not be sent. Please contact your administrator to verify your account.';
|
||||
$answer['verify_url'] = $verify_url;
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Unexpected error — log details server-side, return generic message to client
|
||||
|
||||
Reference in New Issue
Block a user