Skip to content

Commit

Permalink
examples: check array length before access (#21641)
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-db authored Jun 4, 2024
1 parent 1e86e06 commit 096226b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/vweb_fullstack/src/auth_services.v
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ fn (mut app App) service_auth(username string, password string) !string {
users := sql db {
select from User where username == username
}!
if users.len == 0 {
return error('user not found')
}
user := users.first()
if user.username != username {
return error('user not found')
Expand Down

0 comments on commit 096226b

Please sign in to comment.