fixed id parsing
This commit is contained in:
+12
-7
@@ -10,6 +10,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -51,13 +52,17 @@ func (n *Note) Fraud() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func save(c echo.Context, db *sql.DB, n *Note) (*Note, error) {
|
func save(c echo.Context, db *sql.DB, n *Note) (*Note, error) {
|
||||||
if n.Password != "" {
|
|
||||||
clean := n.Password
|
if n.Password == "" {
|
||||||
n.Password = fmt.Sprintf("%x", sha256.Sum256([]byte(n.Password)))
|
n.Password = "kek"
|
||||||
h := md5.New()
|
|
||||||
h.Write([]byte(clean))
|
|
||||||
n.DeprecatedPassword = fmt.Sprintf("%x", h.Sum(nil))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clean := n.Password
|
||||||
|
n.Password = fmt.Sprintf("%x", sha256.Sum256([]byte(n.Password)))
|
||||||
|
h := md5.New()
|
||||||
|
h.Write([]byte(clean))
|
||||||
|
n.DeprecatedPassword = fmt.Sprintf("%x", h.Sum(nil))
|
||||||
|
|
||||||
if n.ID == "" {
|
if n.ID == "" {
|
||||||
return insert(c, db, n)
|
return insert(c, db, n)
|
||||||
}
|
}
|
||||||
@@ -142,7 +147,7 @@ func randId() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func load(c echo.Context, db *sql.DB) (*Note, int) {
|
func load(c echo.Context, db *sql.DB) (*Note, int) {
|
||||||
q := c.Param("id")
|
q, _ := url.QueryUnescape(c.Param("id"))
|
||||||
c.Logger().Debugf("loading note %s", q)
|
c.Logger().Debugf("loading note %s", q)
|
||||||
stmt, _ := db.Prepare("select * from notes where id = ?")
|
stmt, _ := db.Prepare("select * from notes where id = ?")
|
||||||
defer stmt.Close()
|
defer stmt.Close()
|
||||||
|
|||||||
Reference in New Issue
Block a user