mirror of
https://github.com/vlang/v.git
synced 2025-09-10 16:00:31 -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 {
|
users := sql db {
|
||||||
select from User where username == username
|
select from User where username == username
|
||||||
}!
|
}!
|
||||||
|
if users.len == 0 {
|
||||||
|
return error('user not found')
|
||||||
|
}
|
||||||
user := users.first()
|
user := users.first()
|
||||||
if user.username != username {
|
if user.username != username {
|
||||||
return error('user not found')
|
return error('user not found')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user