Skip to content

Commit

Permalink
Fixed bug with DeleteHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Ju-Wiluis William Rodriguez Hernandez committed Jun 23, 2024
1 parent 3de4446 commit 859e6e1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions handlers/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ import (
"net/http"

"github.com/Luis97lol/auth-service/database"
"github.com/Luis97lol/auth-service/redis"
"github.com/gorilla/mux"
)

func DeleteHandler(w http.ResponseWriter, r *http.Request) {
// Read token from Authorization header
LogoutHandler(w, r)
vars := mux.Vars(r)
oid := vars["oid"]
userId := vars["userId"]

token := extractToken(r.Header.Get("Authorization"))
// Validate token against Redis
_, err := redis.ValidateToken(token)
if err == nil {
redis.DeleteToken(token, userId)
}

database.DeleteUser(oid, userId)

// Respond with username
Expand Down

0 comments on commit 859e6e1

Please sign in to comment.