Skip to content

Commit

Permalink
fix cache on email update [fix #18]
Browse files Browse the repository at this point in the history
  • Loading branch information
zekroTJA committed Apr 22, 2020
1 parent 16cb49e commit 208b984
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/webserver/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,9 @@ func (ws *WebServer) handlerPostMail(ctx *routing.Context) error {
return jsonError(ctx, err, fasthttp.StatusInternalServerError)
}

user.MailAddress = ""
ws.cache.SetUserByID(user.UID, user)

return jsonResponse(ctx, nil, fasthttp.StatusOK)
}

Expand Down Expand Up @@ -738,6 +741,11 @@ func (ws *WebServer) handlerPostConfirmMail(ctx *routing.Context) error {
return jsonError(ctx, err, fasthttp.StatusInternalServerError)
}

if user, err := ws.cache.GetUserByID(data.UserID); err == nil && user != nil {
user.MailAddress = data.MailAddress
ws.cache.SetUserByID(user.UID, user)
}

return jsonResponse(ctx, err, fasthttp.StatusOK)
}

Expand Down

0 comments on commit 208b984

Please sign in to comment.