update/teacher password

This commit is contained in:
SowinskiBraeden committed 2022-02-14 14:06:47 -08:00
1 parent 95b466f3ef
commit 44f9db6266
2 files changed
+110 -3

No files matched your search

+9
View File
@@ -55,6 +55,15 @@ type Teacher struct {
Updated_at time.Time `json:"updated_at"`
}
func (t *Teacher) UsedPassword(password string) bool {
for _, oldHash := range t.AccountData.HashHistory {
if oldHash == t.HashPassword(password) {
return true
}
}
return false
}
func (t *Teacher) HashPassword(password string) string {
hash, _ := bcrypt.GenerateFromPassword([]byte(password), 14)
return string(hash)