This commit is contained in:
Lizandro Guarnizo
2026-05-15 14:46:11 -05:00
parent b340d29583
commit d7fe292f05
4 changed files with 104 additions and 2 deletions
+30
View File
@@ -77,3 +77,33 @@ func GeneratePasswordResetURL(email string, baseURL string) string {
uri := fmt.Sprintf("%s/reset-password?t=%s", baseURL, token)
return uri
}
// SendPortalCredentialsEmail envía al usuario del portal su URL de acceso y contraseña inicial.
func SendPortalCredentialsEmail(email, nombre, password string) {
loginURL := fmt.Sprintf("%s/portal/login", app.Http.Server.Url)
htmlBody := fmt.Sprintf(`<!DOCTYPE html>
<html><body style="font-family:Inter,sans-serif;background:#f1f5f9;padding:32px">
<div style="max-width:480px;margin:0 auto;background:#fff;border-radius:16px;padding:32px;border:1px solid #e2e8f0">
<div style="text-align:center;margin-bottom:24px">
<div style="width:48px;height:48px;border-radius:50%%;background:#8eb02f;display:inline-flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:20px">U</div>
<h2 style="margin:12px 0 4px;color:#1e293b">Portal de Clientes</h2>
<p style="color:#64748b;font-size:14px;margin:0">Acceso a tu espacio de trabajo</p>
</div>
<p style="color:#334155;font-size:15px">Hola <strong>%s</strong>,</p>
<p style="color:#334155;font-size:14px">Tu cuenta en el Portal de Clientes ha sido creada. Usa los siguientes datos para ingresar:</p>
<div style="background:#f8fafc;border-radius:10px;padding:16px;margin:20px 0;border:1px solid #e2e8f0">
<p style="margin:0 0 8px;font-size:13px;color:#64748b"><strong>Email:</strong> %s</p>
<p style="margin:0 0 8px;font-size:13px;color:#64748b"><strong>Contraseña:</strong> %s</p>
<p style="margin:0;font-size:13px;color:#64748b"><strong>Enlace de acceso:</strong> <a href="%s" style="color:#8eb02f">%s</a></p>
</div>
<a href="%s" style="display:block;text-align:center;background:#8eb02f;color:#fff;padding:12px 24px;border-radius:10px;font-weight:600;text-decoration:none;font-size:15px">Ingresar al Portal</a>
<p style="font-size:12px;color:#94a3b8;margin-top:24px;text-align:center">Si no esperabas este correo, puedes ignorarlo.</p>
</div>
</body></html>`, nombre, email, password, loginURL, loginURL, loginURL)
go func() {
if err := app.Http.Mail.Send(email, "Acceso a tu Portal de Clientes - U-site", htmlBody, ""); err != nil {
log.Printf("[Portal] Error enviando credenciales a %s: %v", email, err)
}
}()
}