enroll controller + db connection
This commit is contained in:
1 parent
b069ee1aa2
commit
f8d006fe8b
12 files changed
+186
-48
No files matched your search
+19
-1
@@ -1,6 +1,11 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
@@ -12,7 +17,7 @@ type Student struct {
|
||||
Age int `json:"age" validate:"required"`
|
||||
GradeLevel int `json:"gradelevel" validate:"required"`
|
||||
Email string `json:"email" validate:"required"`
|
||||
Password string `json:"password" validate:"required,min=8,max=32"`
|
||||
Password []byte `json:"password" validate:"required,min=8,max=32"`
|
||||
SID string `json:"sid"` // Student ID
|
||||
PED string `json:"ped"` // Personal Education Number
|
||||
Homeroom string `json:"homeroom"`
|
||||
@@ -25,4 +30,17 @@ type Student struct {
|
||||
DOB string `json:"dob" validate:"required"`
|
||||
Photo string `json:"photo"`
|
||||
Contacts []Contact `json:"contacts"`
|
||||
Created_at time.Time `json:"created_at"`
|
||||
Updated_at time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (s *Student) HashPassword(password string) []byte {
|
||||
hashPass, _ := bcrypt.GenerateFromPassword([]byte(password), 14)
|
||||
return hashPass
|
||||
}
|
||||
|
||||
func (s *Student) GenerateSchoolEmail() string {
|
||||
var email string = strings.ToLower(string(s.FirstName[0])) + "." + strings.ToLower(s.LastName) + "@surreyschools.ca"
|
||||
// Add check to see if email already exists
|
||||
return email
|
||||
}
|
||||
Reference in new issue
Block a user