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 {
|
users := sql db {
|
||||||
select from User where username == username
|
select from User where username == username
|
||||||
}!
|
}!
|
||||||
user := users.first()
|
if users.len == 0 {
|
||||||
if user.username != username {
|
|
||||||
return error('user not found')
|
return error('user not found')
|
||||||
}
|
}
|
||||||
|
user := users.first()
|
||||||
|
|
||||||
if !user.active {
|
if !user.active {
|
||||||
return error('user is not active')
|
return error('user is not active')
|
||||||
@ -1010,16 +1010,16 @@ fn (mut app App) service_get_user(id int) !User {
|
|||||||
println(err)
|
println(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer {
|
defer {
|
||||||
db.close() or { panic(err) }
|
db.close() or { panic(err) }
|
||||||
}
|
}
|
||||||
|
|
||||||
results := sql db {
|
results := sql db {
|
||||||
select from User where id == id
|
select from User where id == id
|
||||||
}!
|
}!
|
||||||
|
if results.len == 0 {
|
||||||
return results.first()
|
return error('no results')
|
||||||
|
}
|
||||||
|
return results[0]
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user