Getting username from basic auth, removing excess logging
This commit is contained in:
parent
32f77e0ae1
commit
c54d50d3fc
|
|
@ -13,6 +13,17 @@ import (
|
||||||
"code.springupsoftware.com/cmc/cmc-sales/internal/cmc/templates"
|
"code.springupsoftware.com/cmc/cmc-sales/internal/cmc/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Import getUsername from pages.go
|
||||||
|
// If you move getUsername to a shared utils package, update the import accordingly.
|
||||||
|
func getUsername(r *http.Request) string {
|
||||||
|
username, _, ok := r.BasicAuth()
|
||||||
|
if ok && username != "" {
|
||||||
|
// Capitalise the username for display
|
||||||
|
return strings.Title(username)
|
||||||
|
}
|
||||||
|
return "Guest"
|
||||||
|
}
|
||||||
|
|
||||||
// Helper: returns date string or empty if zero
|
// Helper: returns date string or empty if zero
|
||||||
func formatDate(t time.Time) string {
|
func formatDate(t time.Time) string {
|
||||||
if t.IsZero() || t.Year() == 1970 {
|
if t.IsZero() || t.Year() == 1970 {
|
||||||
|
|
@ -201,6 +212,7 @@ func (h *QuotesHandler) QuotesOutstandingView(w http.ResponseWriter, r *http.Req
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
"RecentlyExpiredQuotes": recentlyExpiredQuotes,
|
"RecentlyExpiredQuotes": recentlyExpiredQuotes,
|
||||||
"ExpiringSoonQuotes": expiringSoonQuotes,
|
"ExpiringSoonQuotes": expiringSoonQuotes,
|
||||||
|
"User": getUsername(r),
|
||||||
}
|
}
|
||||||
if err := h.tmpl.Render(w, "quotes/index.html", data); err != nil {
|
if err := h.tmpl.Render(w, "quotes/index.html", data); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
|
@ -292,9 +304,7 @@ func (h *QuotesHandler) DailyQuoteExpirationCheck() {
|
||||||
fmt.Println("Running DailyQuoteExpirationCheck...")
|
fmt.Println("Running DailyQuoteExpirationCheck...")
|
||||||
|
|
||||||
reminderJobs := []quoteReminderJob{
|
reminderJobs := []quoteReminderJob{
|
||||||
{5, FirstReminder, "Reminder: Quote %s Expires Soon", "first_reminder.html"}, // FOR TESTING
|
|
||||||
{7, FirstReminder, "Reminder: Quote %s Expires Soon", "first_reminder.html"},
|
{7, FirstReminder, "Reminder: Quote %s Expires Soon", "first_reminder.html"},
|
||||||
{-3, SecondReminder, "Follow-Up: Quote %s Expired", "second_reminder.html"}, // FOR TESTING
|
|
||||||
{-7, SecondReminder, "Follow-Up: Quote %s Expired", "second_reminder.html"},
|
{-7, SecondReminder, "Follow-Up: Quote %s Expired", "second_reminder.html"},
|
||||||
{-60, ThirdReminder, "Final Reminder: Quote %s Closed", "final_reminder.html"},
|
{-60, ThirdReminder, "Final Reminder: Quote %s Closed", "final_reminder.html"},
|
||||||
}
|
}
|
||||||
|
|
@ -307,7 +317,6 @@ func (h *QuotesHandler) DailyQuoteExpirationCheck() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(quotes) == 0 {
|
if len(quotes) == 0 {
|
||||||
fmt.Printf("No %s emails to send for day offset %d.\n", job.ReminderType.String(), job.DayOffset)
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, q := range quotes {
|
for _, q := range quotes {
|
||||||
|
|
|
||||||
BIN
go-app/server
BIN
go-app/server
Binary file not shown.
Loading…
Reference in a new issue