示例#1
0
func (service *membershipService) Create(reg models.Registration) (models.Registration, error) {
	reg.Password = encrypt(reg.Password)
	id, err := service.tbl.Create(reg)
	reg.ID = id
	reg.Password = ""
	return reg, err
}
示例#2
0
func (service *membershipService) Login(reg models.Registration) (models.Registration, error) {
	res, err := service.tbl.Search("email='" + reg.Email + "'")
	if len(res) == 0 {
		return reg, errors.New("invalid username: "******""
		reg.ID = match.ID
		return reg, err

	}
	return reg, errors.New("invalid password")

}
示例#3
0
func (service *membershipService) Update(reg models.Registration) (models.Registration, error) {
	reg.Password = encrypt(reg.Password)
	err := service.tbl.Update(reg.ID, reg)
	reg.Password = ""
	return reg, err
}