forked from vieter-v/vieter
feat(api): prevent invalid kind values
This commit is contained in:
parent
bb5643bb03
commit
bd07964509
4 changed files with 21 additions and 10 deletions
|
|
@ -52,6 +52,11 @@ fn (mut app App) v1_post_target() web.Result {
|
|||
return app.json(http.Status.bad_request, new_response(err.msg()))
|
||||
}
|
||||
|
||||
// Ensure someone doesn't submit an invalid kind
|
||||
if new_repo.kind !in models.valid_kinds {
|
||||
return app.json(http.Status.bad_request, new_response('Invalid kind.'))
|
||||
}
|
||||
|
||||
app.db.add_target(new_repo)
|
||||
|
||||
return app.json(http.Status.ok, new_response('Repo added successfully.'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue