|
|
@@ -2346,7 +2346,7 @@ func getEstimates(db *sql.DB, id int, user int) ([]Estimate, error) { |
|
|
|
} |
|
|
|
|
|
|
|
// Prevents runtime panics |
|
|
|
if len(estimates) == 0 { |
|
|
|
if len(estimates) == 0 && id > 0 { |
|
|
|
return estimates, errors.New("Estimate not found.") |
|
|
|
} |
|
|
|
|
|
|
@@ -3594,7 +3594,7 @@ func verificationToken(id int) (string, error) { |
|
|
|
func verifyUser(w http.ResponseWriter, db *sql.DB, r *http.Request) { |
|
|
|
var claims VerificationClaims |
|
|
|
|
|
|
|
params, err := url.ParseQuery(r.URL.Path) |
|
|
|
params, err := url.ParseQuery(r.URL.RawQuery) |
|
|
|
if err != nil { |
|
|
|
w.WriteHeader(500) |
|
|
|
log.Println(err) |
|
|
@@ -3611,7 +3611,7 @@ func verifyUser(w http.ResponseWriter, db *sql.DB, r *http.Request) { |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
w.WriteHeader(500) |
|
|
|
log.Println("Could not parse verification claim.") |
|
|
|
log.Println("Could not parse verification claim.", err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
@@ -3626,7 +3626,10 @@ func verifyUser(w http.ResponseWriter, db *sql.DB, r *http.Request) { |
|
|
|
err = user.update(db) |
|
|
|
|
|
|
|
log.Println("User verified:", user.Id, user.Email) |
|
|
|
w.Write([]byte("Verification complete.")) |
|
|
|
http.Redirect(w, |
|
|
|
r, "https://"+os.Getenv("SKOUTER_DOMAIN"), |
|
|
|
http.StatusTemporaryRedirect) |
|
|
|
// w.Write([]byte("Verification complete.")) |
|
|
|
} |
|
|
|
|
|
|
|
func (user *User) sendVerificationEmail() { |
|
|
@@ -3901,6 +3904,18 @@ func dbReset(db *sql.DB) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func dbDefaults(db *sql.DB) { |
|
|
|
b, err := migrations.ReadFile("migrations/1_12062024_seed_defaults.sql") |
|
|
|
if err != nil { |
|
|
|
log.Fatal(err) |
|
|
|
} |
|
|
|
|
|
|
|
_, err = db.Exec(string(b)) |
|
|
|
if err != nil { |
|
|
|
log.Fatal(err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func generateFees(loan Loan) []Fee { |
|
|
|
var fees []Fee |
|
|
|
var fee Fee |
|
|
@@ -4187,6 +4202,8 @@ func dev(args []string) { |
|
|
|
dbSeed(db) |
|
|
|
case "reset": |
|
|
|
dbReset(db) |
|
|
|
case "defaults": |
|
|
|
dbDefaults(db) |
|
|
|
default: |
|
|
|
return |
|
|
|
} |
|
|
|