From 01d3631b893b09ec4c5f9daade727e8f88aa8d22 Mon Sep 17 00:00:00 2001 From: Ryan Mehri Date: Sun, 10 May 2020 17:32:31 -0600 Subject: Add password hashing --- backend/api/routes.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backend/api') diff --git a/backend/api/routes.go b/backend/api/routes.go index 3b08781..d578632 100644 --- a/backend/api/routes.go +++ b/backend/api/routes.go @@ -31,7 +31,7 @@ func insertFunc(w http.ResponseWriter, r *http.Request) { log.Infof("got content '%s' and ip '%s'", content, ip) // insert content - paste, err := db.New(ip, content, expiry, title, password) + hash, err := db.New(ip, content, expiry, title, password) if err != nil { w.WriteHeader(http.StatusBadRequest) fmt.Fprintf(w, "got err: %s", err.Error()) @@ -40,8 +40,7 @@ func insertFunc(w http.ResponseWriter, r *http.Request) { // if successful return paste hash w.Header().Set("Content-Type", "application/json") pasteMap := map[string]interface{}{ - "hash": paste.Hash, - "password": paste.Password, + "hash": hash, } jsonData, _ := json.Marshal(pasteMap) @@ -59,10 +58,11 @@ func getHashFunc(w http.ResponseWriter, r *http.Request) { return } - // otherwise, return paste content and current time + // otherwise, return paste content, title, and current time w.Header().Set("Content-Type", "application/json") pasteMap := map[string]interface{}{ "timestamp": time.Now(), + "title": paste.Title, "content": paste.Content, } -- cgit v1.2.3