Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
Signed-off-by: William <[email protected]>
  • Loading branch information
kwesidev committed Dec 16, 2023
1 parent 4f672fc commit b1a955d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions internal/controllers/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewUserController(db *sql.DB) *UserController {

// Index Welcome user
func (usrCtrl *UserController) Index(w http.ResponseWriter, r *http.Request) {
userId := utilities.GetUserIdFromHttpConext(r)
userId := utilities.GetUserIdFromHttpContext(r)
userDetails := usrCtrl.userService.Get(userId)
utilities.JSONResponse(w, userDetails)
}
Expand All @@ -52,7 +52,7 @@ func (usrCtrl *UserController) Update(w http.ResponseWriter, r *http.Request) {
utilities.JSONError(w, err.Error(), http.StatusBadRequest)
return
}
userId := utilities.GetUserIdFromHttpConext(r)
userId := utilities.GetUserIdFromHttpContext(r)
response := models.SuccessResponse{}
err = usrCtrl.userService.Update(userId, userUpdateRequest)
if err != nil {
Expand All @@ -73,7 +73,7 @@ func (usrCtrl *UserController) Logout(w http.ResponseWriter, r *http.Request) {
return
}
response := models.SuccessResponse{}
userId := utilities.GetUserIdFromHttpConext(r)
userId := utilities.GetUserIdFromHttpContext(r)
success, err := usrCtrl.userService.DeleteToken(userId, tokenRefreshRequest.RefreshToken)
if err != nil {
response.Success = false
Expand All @@ -92,7 +92,7 @@ func (usrCtrl *UserController) EnableTwoFactor(w http.ResponseWriter, r *http.Re
utilities.JSONError(w, err.Error(), http.StatusBadRequest)
return
}
userId := utilities.GetUserIdFromHttpConext(r)
userId := utilities.GetUserIdFromHttpContext(r)
if enableTwoFactorRequest.Method == "TOTP" {
totpResponse, err := usrCtrl.userService.EnableTwoFactorTOTP(userId)
if err != nil {
Expand Down Expand Up @@ -128,7 +128,7 @@ func (usrCtrl *UserController) VerifyPassCode(w http.ResponseWriter, r *http.Req
utilities.JSONError(w, err.Error(), http.StatusBadRequest)
return
}
userId := utilities.GetUserIdFromHttpConext(r)
userId := utilities.GetUserIdFromHttpContext(r)
response := models.SuccessResponse{}
if usrCtrl.authService.VerifyPassCode(userId, verifyPassCodeRequest.Code) {
response.Success = true
Expand Down
2 changes: 1 addition & 1 deletion internal/utilities/http_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

// GetUserId from bearer token stored in http header
func GetUserIdFromHttpConext(r *http.Request) int {
func GetUserIdFromHttpContext(r *http.Request) int {
claims := r.Context().Value("claims").(map[string]interface{})
userId := claims["userId"].(int)
return userId
Expand Down

0 comments on commit b1a955d

Please sign in to comment.