debug db queries
This commit is contained in:
4 files changed
+27
-28
No files matched your search
@@ -646,20 +646,19 @@ func StudentLogin(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
var verified bool = student.ComparePasswords(data["password"])
|
var verified bool = student.ComparePasswords(data["password"])
|
||||||
var localAccountDisabled bool = false
|
var localAccountDisabled bool = false
|
||||||
var localAttempts int = student.Account.Attempts
|
|
||||||
|
|
||||||
if !verified {
|
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
|
localAccountDisabled = true // Catches newly disbaled account before student obj is updated
|
||||||
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"Account.accountdisabled": true,
|
"account.accountdisabled": true,
|
||||||
"Account.alerted": true,
|
"account.alerted": true,
|
||||||
"Account.attempts": 0,
|
"account.attempts": 0,
|
||||||
"updated_at": update_time,
|
"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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"Account.attempts": (student.Account.Attempts + 1),
|
"account.attempts": (student.Account.Attempts + 1),
|
||||||
"updated_at": update_time,
|
"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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"Account.attempts": 0,
|
"account.attempts": 0,
|
||||||
"updated_at": update_time,
|
"updated_at": update_time,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,9 +369,9 @@ func RemoveStudentsDisabled(c *fiber.Ctx) error {
|
|||||||
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"Account.accountdisabled": false,
|
"account.accountdisabled": false,
|
||||||
"Account.alerted": false,
|
"account.alerted": false,
|
||||||
"Account.attempts": 0,
|
"account.attempts": 0,
|
||||||
"updated_at": update_time,
|
"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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"Account.accountdisabled": false,
|
"account.accountdisabled": false,
|
||||||
"Account.attempts": 0,
|
"account.attempts": 0,
|
||||||
"updated_at": update_time,
|
"updated_at": update_time,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ func UpdateStudentGradeLevel(c *fiber.Ctx) error {
|
|||||||
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"School.gradelevel": data["gradelevel"].(float64),
|
"school.gradelevel": data["gradelevel"].(float64),
|
||||||
"updated_at": update_time,
|
"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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"School.homeroom": data["homeroom"],
|
"school.homeroom": data["homeroom"],
|
||||||
"updated_at": update_time,
|
"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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"Account.password": student.HashPassword(data["newpassword1"]),
|
"account.password": student.HashPassword(data["newpassword1"]),
|
||||||
"Account.temppassword": false, // If it were a temp password, its not now
|
"account.temppassword": false, // If it were a temp password, its not now
|
||||||
"updated_at": update_time,
|
"updated_at": update_time,
|
||||||
},
|
},
|
||||||
"$push": bson.M{
|
"$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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"Account.password": student.HashPassword(tempPass),
|
"account.password": student.HashPassword(tempPass),
|
||||||
"Account.temppassword": true,
|
"account.temppassword": true,
|
||||||
"updated_at": update_time,
|
"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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"School.locker": locker.ID,
|
"school.locker": locker.ID,
|
||||||
"updated_at": update_time,
|
"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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"School.yog": data["yog"].(int),
|
"school.yog": data["yog"].(int),
|
||||||
"updated_at": update_time,
|
"updated_at": update_time,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func UpdateTeacherHomeroom(c *fiber.Ctx) error {
|
|||||||
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
update_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"School.homeroom": data["homeroom"],
|
"school.homeroom": data["homeroom"],
|
||||||
"updated_at": update_time,
|
"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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"Account.password": teacher.HashPassword(data["newpassword1"]),
|
"account.password": teacher.HashPassword(data["newpassword1"]),
|
||||||
"Account.temppassword": false, // If it were a temp password, its not now
|
"account.temppassword": false, // If it were a temp password, its not now
|
||||||
"updated_at": update_time,
|
"updated_at": update_time,
|
||||||
},
|
},
|
||||||
"$push": bson.M{
|
"$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_time, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
update := bson.M{
|
update := bson.M{
|
||||||
"$set": bson.M{
|
"$set": bson.M{
|
||||||
"Account.password": teacher.HashPassword(tempPass),
|
"account.password": teacher.HashPassword(tempPass),
|
||||||
"Account.temppassword": true,
|
"account.temppassword": true,
|
||||||
"updated_at": update_time,
|
"updated_at": update_time,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user