Skip to content

Commit

Permalink
🐛 chore: email from request
Browse files Browse the repository at this point in the history
  • Loading branch information
perebaj committed Sep 29, 2023
1 parent a033b6e commit 3de62cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/transactionhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func RegisterSwaggerHandler(r chi.Router) {
}

func (s transactionHandler) producerBalance(w http.ResponseWriter, r *http.Request) {
email, err := emailFromToken(r)
email, err := emailFromRequest(r)
if err != nil {
sendErr(w, http.StatusBadRequest, Error{"email_required", "email is required"})
return
Expand All @@ -90,7 +90,7 @@ func (s transactionHandler) producerBalance(w http.ResponseWriter, r *http.Reque
}

func (s transactionHandler) affiliateBalance(w http.ResponseWriter, r *http.Request) {
email, err := emailFromToken(r)
email, err := emailFromRequest(r)
if err != nil {
sendErr(w, http.StatusBadRequest, Error{"email_required", "email is required"})
return
Expand All @@ -116,7 +116,7 @@ func (s transactionHandler) affiliateBalance(w http.ResponseWriter, r *http.Requ
}

func (s transactionHandler) upload(w http.ResponseWriter, r *http.Request) {
email, err := emailFromToken(r)
email, err := emailFromRequest(r)
if err != nil {
sendErr(w, http.StatusBadRequest, Error{"email_required", "email is required"})
return
Expand Down Expand Up @@ -217,7 +217,7 @@ func (t *Transaction) Convert(email string) (*contractus.Transaction, error) {
return transac, nil
}

func emailFromToken(r *http.Request) (string, error) {
func emailFromRequest(r *http.Request) (string, error) {
_, claims, err := jwtauth.FromContext(r.Context())
if err != nil {
return "", fmt.Errorf("failed to get claims from context: %v", err)
Expand Down

0 comments on commit 3de62cc

Please sign in to comment.