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 }
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") }
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 }