simplify naming

This commit is contained in:
SowinskiBraeden committed 2023-01-07 17:14:00 -08:00
1 parent 4c4bad4be0
commit b140869281
7 files changed
+58 -58

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ type Admin struct {
func (a *Admin) EmailExists(email string) bool {
var admin Admin
findErr := AdminCollection.FindOne(context.TODO(), bson.M{"accountdata.schoolemail": email}).Decode(&admin)
findErr := AdminCollection.FindOne(context.TODO(), bson.M{"Account.schoolemail": email}).Decode(&admin)
return findErr == nil
}
+5 -5
View File
@@ -45,7 +45,7 @@ type Student struct {
YOG int `json:"yog"` // Year of Graduation
PhotoName string `json:"photoname"` // name of photo in db
} `json:"schooldata"`
AccountData struct {
Account struct {
VerifiedEmail bool `json:"verifiedemail"`
SchoolEmail string `json:"schoolemail"`
Password string `json:"-" validate:"min=10,max=32"`
@@ -54,13 +54,13 @@ type Student struct {
TempPassword bool `json:"temppassword"`
Attempts int `json:"attempts"` // login attempts max 5
HashHistory []string `json:"-"` // List of old hashed passwords (not including auto generated passwords)
} `json:"accountdata"`
} `json:"Account"`
Created_at time.Time `json:"created_at"`
Updated_at time.Time `json:"updated_at"`
}
func (s *Student) UsedPassword(password string) bool {
for _, oldHash := range s.AccountData.HashHistory {
for _, oldHash := range s.Account.HashHistory {
if oldHash == s.HashPassword(password) {
return true
}
@@ -75,7 +75,7 @@ func (s *Student) HashPassword(password string) string {
func (s *Student) EmailExists(email string) bool {
var student Student
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"accountdata.schoolemail": email}).Decode(&student)
findErr := StudentCollection.FindOne(context.TODO(), bson.M{"Account.schoolemail": email}).Decode(&student)
return findErr == nil
}
@@ -95,7 +95,7 @@ func (s *Student) GenerateSchoolEmail(offset int, lastEmail string) string {
}
func (s *Student) ComparePasswords(password string) bool { //True: passwords match, False: no match
valid := bcrypt.CompareHashAndPassword([]byte(s.AccountData.Password), []byte(password))
valid := bcrypt.CompareHashAndPassword([]byte(s.Account.Password), []byte(password))
return valid == nil
}
+5 -5
View File
@@ -44,7 +44,7 @@ type Teacher struct {
Homeroom string `json:"homeroom"`
PhotoName string `json:"photoname"` // name of photo in db
} `json:"schooldata"`
AccountData struct {
Account struct {
VerifiedEmail bool `json:"verifiedemail"`
SchoolEmail string `json:"schoolemail"`
Password string `json:"-" validate:"min=10,max=32"`
@@ -52,13 +52,13 @@ type Teacher struct {
TempPassword bool `json:"temppassword"`
Attempts int `json:"attempts"` // login attempts max 5
HashHistory []string `json:"-"` // List of old hashed passwords (not including auto generated passwords)
} `json:"accountdata"`
} `json:"Account"`
Created_at time.Time `json:"created_at"`
Updated_at time.Time `json:"updated_at"`
}
func (t *Teacher) UsedPassword(password string) bool {
for _, oldHash := range t.AccountData.HashHistory {
for _, oldHash := range t.Account.HashHistory {
if oldHash == t.HashPassword(password) {
return true
}
@@ -73,7 +73,7 @@ func (t *Teacher) HashPassword(password string) string {
func (t *Teacher) EmailExists(email string) bool {
var teacher Teacher
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"accountdata.schoolemail": email}).Decode(&teacher)
findErr := TeacherCollection.FindOne(context.TODO(), bson.M{"Account.schoolemail": email}).Decode(&teacher)
return findErr == nil
}
@@ -93,7 +93,7 @@ func (t *Teacher) GenerateSchoolEmail(offset int, lastEmail string) string {
}
func (t *Teacher) ComparePasswords(password string) bool {
err := bcrypt.CompareHashAndPassword([]byte(t.AccountData.Password), []byte(password))
err := bcrypt.CompareHashAndPassword([]byte(t.Account.Password), []byte(password))
return err == nil
}