@@ -243,9 +243,8 @@ function start() { | |||
this.refreshToken() | |||
fetchUser().then( u => { | |||
if (u.sub.customerId && | |||
validStatuses.includes(u.sub.paymentStatus) && | |||
this.user.status != "Unsubscribed" || | |||
this.user.status != "Subscribed") { | |||
validStatuses.includes(u.sub.status) && | |||
this.user.status != "Unsubscribed") { | |||
return | |||
} | |||
// Payment must be updated | |||
@@ -91,7 +91,6 @@ const example = { | |||
pud: true, // Property under development | |||
zip: '', | |||
fees: [], | |||
mi: { monthly: false, rate: 0 } | |||
} | |||
// The default loans on a new estimate | |||
@@ -121,6 +120,9 @@ function create() { | |||
example, {fees: this.createFees()} | |||
) | |||
) | |||
// Move current loan to last inserted | |||
this.sel = this.estimate.loans.length - 1 | |||
} | |||
@@ -97,8 +97,8 @@ CREATE TABLE license ( | |||
* Types with branch_id and user_id values of 0 will be general cases. */ | |||
CREATE TABLE loan_type ( | |||
id INT AUTO_INCREMENT, | |||
branch_id INT, | |||
user_id INT, | |||
branch_id INT DEFAULT NULL, | |||
user_id INT DEFAULT NULL, | |||
name VARCHAR(30) UNIQUE NOT NULL, | |||
FOREIGN KEY (branch_id) REFERENCES branch(id), | |||
FOREIGN KEY (user_id) REFERENCES user(id), | |||
@@ -229,3 +229,31 @@ CREATE TABLE estimate_result ( | |||
PRIMARY KEY (`id`), | |||
FOREIGN KEY (loan_id) REFERENCES loan(id) ON DELETE CASCADE | |||
); | |||
INSERT INTO loan_type ( | |||
branch_id, | |||
user_id, | |||
name | |||
) | |||
VALUES (NULL, NULL, 'Conventional'); | |||
INSERT INTO loan_type ( | |||
branch_id, | |||
user_id, | |||
name | |||
) | |||
VALUES (NULL, NULL, 'FHA'); | |||
INSERT INTO loan_type ( | |||
branch_id, | |||
user_id, | |||
name | |||
) | |||
VALUES (NULL, NULL, 'USDA'); | |||
INSERT INTO loan_type ( | |||
branch_id, | |||
user_id, | |||
name | |||
) | |||
VALUES (NULL, NULL, 'VA'); |
@@ -0,0 +1,27 @@ | |||
INSERT INTO loan_type ( | |||
branch_id, | |||
user_id, | |||
name | |||
) | |||
VALUES (NULL, NULL, 'Conventional'); | |||
INSERT INTO loan_type ( | |||
branch_id, | |||
user_id, | |||
name | |||
) | |||
VALUES (NULL, NULL, 'FHA'); | |||
INSERT INTO loan_type ( | |||
branch_id, | |||
user_id, | |||
name | |||
) | |||
VALUES (NULL, NULL, 'USDA'); | |||
INSERT INTO loan_type ( | |||
branch_id, | |||
user_id, | |||
name | |||
) | |||
VALUES (NULL, NULL, 'VA'); |
@@ -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 | |||
} | |||