diff options
| author | Horus3 | 2015-02-10 14:01:31 +0100 |
|---|---|---|
| committer | Horus3 | 2015-02-10 14:01:31 +0100 |
| commit | 5a5d0fd250c28c3560ff00b9a367938e915eed7f (patch) | |
| tree | 145fa031631390a93e41a226ba9dc19190ba27b2 /app/controllers/utilities.go | |
| parent | c7869f2326d4e8282697c6961f39f1b19b4c8c94 (diff) | |
| download | webmon-5a5d0fd250c28c3560ff00b9a367938e915eed7f.tar.gz | |
Restructuring and bug fixes.
Diffstat (limited to 'app/controllers/utilities.go')
| -rw-r--r-- | app/controllers/utilities.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/app/controllers/utilities.go b/app/controllers/utilities.go index 2eae775..1aa5d6d 100644 --- a/app/controllers/utilities.go +++ b/app/controllers/utilities.go @@ -4,7 +4,7 @@ import ( "crypto/md5" "fmt" "github.com/garyburd/redigo/redis" - "github.com/tanema/revel_mailer" + "github.com/revel/revel" "golang.org/x/crypto/bcrypt" "io" "io/ioutil" @@ -22,7 +22,7 @@ func Get(url string) (string, error) { defer response.Body.Close() contents, err := ioutil.ReadAll(response.Body) - if er != nil { + if err != nil { return "Reading body failed.", err } @@ -58,13 +58,7 @@ func newPool() *redis.Pool { IdleTimeout: 240 * time.Second, Dial: func() (redis.Conn, error) { //c, err := redis.Dial("tcp", ":6379") - if revel.Config.Bool("cache.redis") { - // If we use redis as cache we reuse the config part - c, err := redis.Dial("tcp", revel.Config.String("cache.hosts")) - } else { - // Otherwise we use our own configuration - c, err := redis.Dial("tcp", revel.Config.String("redis.server")+":"+revel.Config.String("redis.port")) - } + c, err := redis.Dial("tcp", revel.Config.StringDefault("redis.server", "127.0.0.1")+":"+revel.Config.StringDefault("redis.port", "6379")) if err != nil { return nil, err } @@ -80,19 +74,19 @@ func newPool() *redis.Pool { // Hashs password with bcrypt and returns the string func HashPassword(password string) (string, error) { if password == "" { - return nil, nil + return "", nil } p := []byte(password) hash, err := bcrypt.GenerateFromPassword(p, 10) if err != nil { - return nil, err + return "", err } - return string(hash) + return string(hash), nil } // Verify password and hash func VerifyPassword(password, hash string) (bool, error) { - err := bcrypt.CompareHashAndPassword(hash, password) + err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) if err != nil { return false, err } |
