예제 #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
파일: login.go 프로젝트: nrml/membership-go
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
}