func ChangePassword(id int64, cipher string) error { _, b, err := gos.PraseCipher([]byte(cipher)) if err != nil { return gos.NewError(0, err) } arr := bytes.Split(b, separator) obj := db.DataRow{} obj["salt"], obj["token"] = UserToken(string(arr[0]), arr[1]) _, err = db.NewUpdateBuilder("users").Where("id=?", id).Update(obj) return err }
func Regist(cipher string) error { _, b, err := gos.PraseCipher([]byte(cipher)) if err != nil { return gos.NewError(0, err) } arr := bytes.Split(b, separator) obj := db.DataRow{} obj["nick"] = string(arr[0]) obj["status"] = 1 obj["created_at"] = time.Now() obj["salt"], obj["token"] = UserToken(string(arr[0]), arr[1]) _, err = db.NewInsertBuilder("users").Insert(obj) return err }