aboutsummaryrefslogtreecommitdiff
path: root/backend/api/routes.go
diff options
context:
space:
mode:
authorRyan Mehri <[email protected]>2020-05-10 17:32:31 -0600
committerRyan Mehri <[email protected]>2020-05-10 17:32:31 -0600
commit01d3631b893b09ec4c5f9daade727e8f88aa8d22 (patch)
treee35a25eef106f58ebc7d222e3f51ac5013f04f6e /backend/api/routes.go
parentUpdate post to return hash and password (diff)
downloadctrl-v-01d3631b893b09ec4c5f9daade727e8f88aa8d22.tar.xz
ctrl-v-01d3631b893b09ec4c5f9daade727e8f88aa8d22.zip
Add password hashing
Diffstat (limited to 'backend/api/routes.go')
-rw-r--r--backend/api/routes.go8
1 files changed, 4 insertions, 4 deletions
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,
}