diff --git a/controllers/authController.go b/controllers/authController.go index e2b4ac6..620bf8e 100644 --- a/controllers/authController.go +++ b/controllers/authController.go @@ -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, }, } diff --git a/controllers/update/adminController.go b/controllers/update/adminController.go index 6130970..7c3f98a 100644 --- a/controllers/update/adminController.go +++ b/controllers/update/adminController.go @@ -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, }, } diff --git a/controllers/update/studentController.go b/controllers/update/studentController.go index 15ed24f..8e87c97 100644 --- a/controllers/update/studentController.go +++ b/controllers/update/studentController.go @@ -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, }, } diff --git a/controllers/update/teacherController.go b/controllers/update/teacherController.go index 99a4a16..ffec3b6 100644 --- a/controllers/update/teacherController.go +++ b/controllers/update/teacherController.go @@ -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, }, }