1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools: fix unhandled error in v new api_test web

This commit is contained in:
Delyan Angelov 2023-07-14 16:19:25 +03:00
parent 9047f7c9a8
commit fb11a16ab8
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -506,10 +506,10 @@ fn (mut app App) service_auth(username string, password string) !string {
users := sql db {
select from User where username == username
}!
user := users.first()
if user.username != username {
if users.len == 0 {
return error('user not found')
}
user := users.first()
if !user.active {
return error('user is not active')
@ -1010,16 +1010,16 @@ fn (mut app App) service_get_user(id int) !User {
println(err)
return err
}
defer {
db.close() or { panic(err) }
}
results := sql db {
select from User where id == id
}!
return results.first()
if results.len == 0 {
return error('no results')
}
return results[0]
}
"
}