fix #60: apply ValidExpiry clamp to cans create handler (was lost in working tree)
This commit is contained in:
@@ -40,6 +40,12 @@ func (a *apiServer) handleCreateCan(w http.ResponseWriter, r *http.Request) {
|
|||||||
writeErr(w, 400, "invalid expires_in")
|
writeErr(w, 400, "invalid expires_in")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// #60: clamp at the API boundary like the pastes API does -
|
||||||
|
// reject zero/negative and durations past the 1-year UI cap.
|
||||||
|
if !store.ValidExpiry(d) {
|
||||||
|
writeErr(w, 400, "expires_in must be between 1 minute and 1 year")
|
||||||
|
return
|
||||||
|
}
|
||||||
t := now + int64(d.Seconds())
|
t := now + int64(d.Seconds())
|
||||||
expiresAt = &t
|
expiresAt = &t
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user