Skip to content

Commit

Permalink
Merge pull request #59 from containerish/cleanup
Browse files Browse the repository at this point in the history
fix: initial user signup fix
  • Loading branch information
guacamole authored Nov 2, 2021
2 parents b107b4b + 6fde7ff commit ac6a928
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion auth/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ func (a *auth) SignUp(ctx echo.Context) error {
if err := u.Validate(a.store); err != nil {
return ctx.JSON(http.StatusBadRequest, echo.Map{
"error": err.Error(),
"msg": "bananas",
})
}

Expand Down
12 changes: 8 additions & 4 deletions cache/register_for_beta.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"regexp"

"github.com/dgraph-io/badger/v3"
"github.com/labstack/echo/v4"
)

Expand Down Expand Up @@ -59,17 +60,19 @@ func (ds *dataStore) RegisterForBeta(ctx echo.Context) error {
key := []byte("email")
var value BetaRegister
list, err := ds.Get([]byte("email"))

if err != nil {
if err != nil || err == badger.ErrKeyNotFound {
value.Emails = []string{body["email"]}
if err := ds.Set(key, value.Bytes()); err != nil {
return ctx.JSON(http.StatusInternalServerError, echo.Map{
"error": err.Error(),
})
}
return ctx.JSON(http.StatusOK, echo.Map{
"message": "Success",
})
}

if err := json.Unmarshal(list, &value); err != nil {
if err = json.Unmarshal(list, &value); err != nil {
return ctx.JSON(http.StatusInternalServerError, echo.Map{
"error": err.Error(),
})
Expand Down Expand Up @@ -97,10 +100,11 @@ func (ds *dataStore) RegisterForBeta(ctx echo.Context) error {

func (ds *dataStore) GetAllEmail(ctx echo.Context) error {
bz, err := ds.Get([]byte("email"))
if err != nil {
if err != nil && err != badger.ErrKeyNotFound {
return ctx.JSON(http.StatusInternalServerError, echo.Map{
"error": "couldn't get them all",
})
}

return ctx.JSONBlob(http.StatusOK, bz)
}

0 comments on commit ac6a928

Please sign in to comment.