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:
parent
9047f7c9a8
commit
fb11a16ab8
@ -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]
|
||||
}
|
||||
"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user