mirror of
https://github.com/vlang/v.git
synced 2025-09-09 15:27:05 -04:00
examples: check array length before access (#21641)
This commit is contained in:
parent
1e86e06eb6
commit
096226bf05
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user