forked from Nixius/authelia
1
0
Fork 0

correcting success

This commit is contained in:
Leopere 2026-03-05 15:41:30 -05:00
parent 897e1f6b17
commit ec79638f89
Signed by: colin
SSH Key Fingerprint: SHA256:nRPCQTeMFLdGytxRQmPVK9VXY3/ePKQ5lGRyJhT5DY8
2 changed files with 34 additions and 28 deletions

View File

@ -155,38 +155,33 @@ func (a *App) handleSuccess(w http.ResponseWriter, r *http.Request) {
log.Printf("ldap add to customers failed for %s: %v (create group 'customers' in LLDAP admin if missing)", result.Username, err) log.Printf("ldap add to customers failed for %s: %v (create group 'customers' in LLDAP admin if missing)", result.Username, err)
} }
inGroup, _ := a.ldap.IsInGroup(result.Username, "customers") // New or lapsed: send password-set email so they can create their login.
if result.IsNew {
if result.IsNew || !inGroup {
// New or lapsed: send password email, show success page.
if err := a.triggerPasswordReset(r, result.Username); err != nil { if err := a.triggerPasswordReset(r, result.Username); err != nil {
log.Printf("authelia reset trigger failed for %s: %v", username, err) log.Printf("authelia reset trigger failed for %s: %v", username, err)
} else { } else {
resendRateLimiter.record(result.Username) resendRateLimiter.record(result.Username)
} }
if err := a.tmpl.ExecuteTemplate(w, "success.html", map[string]any{
"AppURL": a.cfg.AppURL,
"Username": result.Username,
}); err != nil {
log.Printf("template error: %v", err)
http.Error(w, "internal error", http.StatusInternalServerError)
}
return
} }
// Returning customer: ensure stack exists (no redirect; show same success page).
// Returning active customer: ensure stack exists, go to dashboard
stackName := fmt.Sprintf("customer-%s", result.Username) stackName := fmt.Sprintf("customer-%s", result.Username)
exists, _ := a.swarm.StackExists(stackName) exists, _ := a.swarm.StackExists(stackName)
if !exists { if !exists {
if err := a.swarm.RestoreVolumes(stackName, a.cfg.ArchivePath); err != nil { if err := a.swarm.RestoreVolumes(stackName, a.cfg.ArchivePath); err != nil {
log.Printf("resubscribe: volume restore failed for %s: %v", result.Username, err) log.Printf("success: volume restore failed for %s: %v", result.Username, err)
} }
if err := a.swarm.DeployStack(stackName, result.Username, a.cfg.TraefikDomain); err != nil { if err := a.swarm.DeployStack(stackName, result.Username, a.cfg.TraefikDomain); err != nil {
log.Printf("resubscribe: stack deploy failed for %s: %v", result.Username, err) log.Printf("success: stack deploy failed for %s: %v", result.Username, err)
} }
} }
log.Printf("resubscribe: %s payment verified, redirecting to dashboard", result.Username) // Always show success page: set password via email first, then dashboard.
http.Redirect(w, r, a.cfg.AppURL+"/dashboard", http.StatusSeeOther) if err := a.tmpl.ExecuteTemplate(w, "success.html", map[string]any{
"AppURL": a.cfg.AppURL,
"Username": result.Username,
}); err != nil {
log.Printf("template error: %v", err)
http.Error(w, "internal error", http.StatusInternalServerError)
}
} }
// handleLinkStripeCustomer creates a Stripe customer for the current user and saves the ID in LDAP, // handleLinkStripeCustomer creates a Stripe customer for the current user and saves the ID in LDAP,

View File

@ -56,6 +56,20 @@
.resend .msg { font-size: 0.85rem; margin-top: 0.5rem; } .resend .msg { font-size: 0.85rem; margin-top: 0.5rem; }
.resend .msg.success { color: var(--green, #22c55e); } .resend .msg.success { color: var(--green, #22c55e); }
.resend .msg.error { color: #ef4444; } .resend .msg.error { color: #ef4444; }
.dashboard-cta { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.dashboard-cta .muted { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.5rem; }
.dashboard-cta .btn-primary {
display: inline-block;
background: var(--accent);
color: #fff;
text-decoration: none;
padding: 0.6rem 1.25rem;
font-size: 0.95rem;
font-weight: 600;
border-radius: 8px;
transition: background 0.2s;
}
.dashboard-cta .btn-primary:hover { background: var(--accent-hover); }
</style> </style>
{{template "analytics"}} {{template "analytics"}}
</head> </head>
@ -63,13 +77,9 @@
<div class="container"> <div class="container">
<div class="logo">a250.ca</div> <div class="logo">a250.ca</div>
<div class="card"> <div class="card">
<h2>Check your inbox</h2> <h2>You're all set</h2>
<p>We've sent a password set email to your address. Use the link in that email to create your password and sign in.</p> <p>You should have received an email from <strong>a250.ca</strong> to set your login. Use the link in that email to create your password and sign in.</p>
<p><strong>You'll be required to:</strong></p> <p><strong>Do that first.</strong> You'll need to set a password and (when prompted) enable two-factor authentication or a passkey.</p>
<ul>
<li>Set a password</li>
<li>Enable two-factor authentication or a passkey</li>
</ul>
<p>Once you've signed in, you can activate your workspace from the dashboard.</p> <p>Once you've signed in, you can activate your workspace from the dashboard.</p>
{{if .Username}} {{if .Username}}
<div class="resend"> <div class="resend">
@ -81,9 +91,10 @@
<p class="msg" id="resend-msg"></p> <p class="msg" id="resend-msg"></p>
</div> </div>
{{end}} {{end}}
</div> <div class="dashboard-cta">
<div class="footer"> <p class="muted">Already set your password?</p>
<a href="{{.AppURL}}/dashboard">Go to Dashboard</a> <a href="{{.AppURL}}/dashboard" class="btn-primary">Go to Dashboard</a>
</div>
</div> </div>
</div> </div>
{{if .Username}} {{if .Username}}