Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/LEARNING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Date: 2025-11-14
## Date: 2025-11-24
### Password Validation

[OWASP](https://owasp.org/) no longer recommends strict composition rules like:
Expand All @@ -9,3 +9,17 @@
Why?

Because composition rules do NOT significantly improve security and they make passwords harder for users to remember!


## Date: 2025-11-25
```go
value := x.(string)
```

This tells go that we expect x to be a string.

```go
str, ok := x.(string)
```

For failure case we can make use of two variables.
21 changes: 19 additions & 2 deletions internal/handler/user/user_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ func (h *UserHandler) UpdatePassword(c *gin.Context) {
return
}

req.ID = userID.(int)
val, ok := userID.(int)
if !ok {
c.JSON(http.StatusBadRequest, common.ErrorResponse{
Message: "invalid userID in context",
})
return
}
req.ID = val

resp, err := h.service.UpdatePassword(&req)
if err != nil {
Expand Down Expand Up @@ -174,7 +181,17 @@ func (h *UserHandler) DeleteUser(c *gin.Context) {
return
}

req := dto.DeleteUserRequest{ID: userID.(int)}
val, ok := userID.(int)
if !ok {
c.JSON(http.StatusBadRequest, common.ErrorResponse{
Message: "invalid userID in context",
})
return
}

req := dto.DeleteUserRequest{
ID: val,
}

resp, err := h.service.DeleteUser(&req)
if err != nil {
Expand Down
Loading