debug db queries

This commit is contained in:
SowinskiBraeden committed 2023-01-10 12:10:30 -08:00
1 parent a092e82f7f
commit 0338189ffa
4 files changed
+27 -28

No files matched your search

+7 -8
View File
@@ -646,20 +646,19 @@ func StudentLogin(c *fiber.Ctx) error {
var verified bool = student.ComparePasswords(data["password"])
var localAccountDisabled bool = false
var localAttempts int = student.Account.Attempts
if !verified {
localAttempts += 1
student.Account.Attempts += 1
}
if student.Account.Attempts >= 5 || localAttempts >= 5 {
if student.Account.Attempts >= 5 {
localAccountDisabled = true // Catches newly disbaled account before student obj is updated
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"Account.accountdisabled": true,
"Account.alerted": true,
"Account.attempts": 0,
"account.accountdisabled": true,
"account.alerted": true,
"account.attempts": 0,
"updated_at": update_time,
},
}
@@ -708,7 +707,7 @@ func StudentLogin(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"Account.attempts": (student.Account.Attempts + 1),
"account.attempts": (student.Account.Attempts + 1),
"updated_at": update_time,
},
}
@@ -735,7 +734,7 @@ func StudentLogin(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"Account.attempts": 0,
"account.attempts": 0,
"updated_at": update_time,
},
}
+5 -5
View File
@@ -369,9 +369,9 @@ func RemoveStudentsDisabled(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"Account.accountdisabled": false,
"Account.alerted": false,
"Account.attempts": 0,
"account.accountdisabled": false,
"account.alerted": false,
"account.attempts": 0,
"updated_at": update_time,
},
}
@@ -432,8 +432,8 @@ func RemoveTeachersDisabled(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"Account.accountdisabled": false,
"Account.attempts": 0,
"account.accountdisabled": false,
"account.attempts": 0,
"updated_at": update_time,
},
}
+9 -9
View File
@@ -135,7 +135,7 @@ func UpdateStudentGradeLevel(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"School.gradelevel": data["gradelevel"].(float64),
"school.gradelevel": data["gradelevel"].(float64),
"updated_at": update_time,
},
}
@@ -206,7 +206,7 @@ func UpdateStudentHomeroom(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"School.homeroom": data["homeroom"],
"school.homeroom": data["homeroom"],
"updated_at": update_time,
},
}
@@ -306,12 +306,12 @@ func UpdateStudentPassword(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"Account.password": student.HashPassword(data["newpassword1"]),
"Account.temppassword": false, // If it were a temp password, its not now
"account.password": student.HashPassword(data["newpassword1"]),
"account.temppassword": false, // If it were a temp password, its not now
"updated_at": update_time,
},
"$push": bson.M{
"Account.hashhistory": student.HashPassword(data["newpassword1"]),
"account.hashhistory": student.HashPassword(data["newpassword1"]),
},
}
@@ -393,8 +393,8 @@ func ResetStudentPassword(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"Account.password": student.HashPassword(tempPass),
"Account.temppassword": true,
"account.password": student.HashPassword(tempPass),
"account.temppassword": true,
"updated_at": update_time,
},
}
@@ -478,7 +478,7 @@ func UpdateStudentLocker(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"School.locker": locker.ID,
"school.locker": locker.ID,
"updated_at": update_time,
},
}
@@ -612,7 +612,7 @@ func UpdateStudentYOG(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"School.yog": data["yog"].(int),
"school.yog": data["yog"].(int),
"updated_at": update_time,
},
}
+6 -6
View File
@@ -61,7 +61,7 @@ func UpdateTeacherHomeroom(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"School.homeroom": data["homeroom"],
"school.homeroom": data["homeroom"],
"updated_at": update_time,
},
}
@@ -161,12 +161,12 @@ func UpdateTeacherPassword(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"Account.password": teacher.HashPassword(data["newpassword1"]),
"Account.temppassword": false, // If it were a temp password, its not now
"account.password": teacher.HashPassword(data["newpassword1"]),
"account.temppassword": false, // If it were a temp password, its not now
"updated_at": update_time,
},
"$push": bson.M{
"Account.hashhistory": teacher.HashPassword(data["newpassword1"]),
"account.hashhistory": teacher.HashPassword(data["newpassword1"]),
},
}
@@ -246,8 +246,8 @@ func ResetTeacherPassword(c *fiber.Ctx) error {
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
update := bson.M{
"$set": bson.M{
"Account.password": teacher.HashPassword(tempPass),
"Account.temppassword": true,
"account.password": teacher.HashPassword(tempPass),
"account.temppassword": true,
"updated_at": update_time,
},
}