Commit 4b4ea384f8c90564e40be2d90ed474b41b4a0947

Authored by Marko Tikvić
1 parent 17a4d04476
Exists in master and in 1 other branch v2

hmm

... ... @@ -27,10 +27,10 @@ type CredentialsStruct struct {
27 27 Password string `json:"password"`
28 28 }
29 29  
30   -func generateSalt() (salt string, error) {
  30 +func generateSalt() (salt string, err error) {
31 31 rawsalt := make([]byte, saltSize)
32 32  
33   - _, err := rand.Read(rawsalt)
  33 + _, err = rand.Read(rawsalt)
34 34 if err != nil {
35 35 return "", err
36 36 }
... ...
format_utility.go
... ... @@ -2,6 +2,7 @@ package restutility
2 2  
3 3 import (
4 4 "time"
  5 + "fmt"
5 6 )
6 7  
7 8 func UnixToDate(unix int64) time.Time {
... ... @@ -19,14 +20,14 @@ func DateToUnix(date interface{}) int64 {
19 20  
20 21 func EqualQuotes(stmt string) string {
21 22 if stmt != "" {
22   - stmt = " = '" + stmt + "'"
  23 + stmt = fmt.Sprintf(" = '%s'", stmt)
23 24 }
24 25 return stmt
25 26 }
26 27  
27 28 func LikeQuotes(stmt string) string {
28 29 if stmt != "" {
29   - stmt " LIKE UPPER('%" + stmt + "%')"
  30 + stmt = fmt.Sprintf(" LIKE UPPER('%%s%')", stmt)
30 31 }
31 32 return stmt
32 33 }
... ...
... ... @@ -60,8 +60,8 @@ func WrapHandler(handlerFunc http.HandlerFunc, needauth bool) http.HandlerFunc {
60 60 "POST, GET, PUT, DELETE, OPTIONS")
61 61  
62 62 w.Header().Set("Access-Control-Allow-Headers",
63   - "Accept, Content-Type, Content-Length, "
64   - "Accept-Encoding, X-CSRF-Token, Authorization")
  63 + `Accept, Content-Type, Content-Length,
  64 + Accept-Encoding, X-CSRF-Token, Authorization`)
65 65  
66 66 w.Header().Set("Content-Type", "application/json; charset=utf-8")
67 67  
... ... @@ -72,7 +72,7 @@ func WrapHandler(handlerFunc http.HandlerFunc, needauth bool) http.HandlerFunc {
72 72 if needauth {
73 73 token := req.Header.Get("Authorization")
74 74 if _, err := ParseAPIToken(token); err != nil {
75   - UnathorizedResponse(w, req, http.StatusUnauthorized)
  75 + UnauthorizedResponse(w, req)
76 76 return
77 77 }
78 78 }
... ...