Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lillian committed Jan 31, 2024
1 parent 0899872 commit 33fc6e7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
# https://github.com/docker/build-push-action/issues/378
context: .
file: Dockerfile
push: false
push: true
tags: |
ghcr.io/hacklabto/members-platform:${{ github.sha }}
2 changes: 1 addition & 1 deletion cmd/web/ui/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func registerPasswdRoutes(r chi.Router) {
MaybeHtmxComponent(rw, r, "passwd", errReply)
return
}
if err := db.RedisDB.Del(context.Background(), "reset-token:"+token).Err(); err != nil {
if err := db.Redis.Del(context.Background(), "reset-token:"+token).Err(); err != nil {
errReply.Error = err.Error()
MaybeHtmxComponent(rw, r, "passwd", errReply)
return
Expand Down
4 changes: 2 additions & 2 deletions internal/auth/resetpassword.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ func CreateResetToken(username string) (string, error) {
return "", fmt.Errorf("failed to read random bytes: %w", err)
}
token := base64.RawURLEncoding.EncodeToString(b)
return token, db.RedisDB.Set(context.Background(), "reset-token:"+token, username, time.Hour*24).Err()
return token, db.Redis.Set(context.Background(), "reset-token:"+token, username, time.Hour*24).Err()
}

func ValidateResetToken(token string) (string, bool) {
v, err := db.RedisDB.Get(context.Background(), "reset-token:"+token).Result()
v, err := db.Redis.Get(context.Background(), "reset-token:"+token).Result()
switch {
case err != nil:
log.Println(err)
Expand Down
6 changes: 3 additions & 3 deletions internal/db/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/redis/go-redis/v9"
)

var RedisDB *redis.Client
var Redis *redis.Client

func ConnectRedis() error {
log.Println("connecting to redis")
Expand All @@ -22,8 +22,8 @@ func ConnectRedis() error {
return err
}

RedisDB = redis.NewClient(opt)
Redis = redis.NewClient(opt)

c := RedisDB.Ping(context.Background())
c := Redis.Ping(context.Background())
return c.Err()
}

0 comments on commit 33fc6e7

Please sign in to comment.