log.Error("Couldn't parse readReq form request: %v\n",err)
returnErrBadFormData
}
err=app.formDecoder.Decode(&readReq,r.PostForm)
iferr!=nil{
log.Error("Couldn't decode readReq form request: %v\n",err)
returnErrBadFormData
}
}
ifreadReq.Alias==""{
returnimpart.HTTPError{http.StatusBadRequest,"Need a collection `alias` to read."}
}
ifreadReq.Pass==""{
returnimpart.HTTPError{http.StatusBadRequest,"Please supply a password."}
}
varcollHashedPass[]byte
err:=app.db.QueryRow("SELECT password FROM collectionpasswords INNER JOIN collections ON id = collection_id WHERE alias = ?",readReq.Alias).Scan(&collHashedPass)
iferr!=nil{
iferr==sql.ErrNoRows{
log.Error("No collectionpassword found when trying to read collection %s",readReq.Alias)
returnimpart.HTTPError{http.StatusInternalServerError,"Something went very wrong. The humans have been alerted."}