forked from jason/cpolis
Added config for Firebase key
This commit is contained in:
@ -12,7 +12,7 @@ import (
|
||||
|
||||
func ServePDFList(c *b.Config) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if tokenIsVerified(w, r) {
|
||||
if tokenIsVerified(w, r, c) {
|
||||
files, err := os.ReadDir(c.PDFDir)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@ -37,7 +37,7 @@ func ServePDFList(c *b.Config) http.HandlerFunc {
|
||||
|
||||
func ServePDF(c *b.Config) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if tokenIsVerified(w, r) {
|
||||
if tokenIsVerified(w, r, c) {
|
||||
http.ServeFile(w, r, fmt.Sprint(c.PDFDir, "/", r.PathValue("id")))
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
func ServeRSS(c *b.Config) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if tokenIsVerified(w, r) {
|
||||
if tokenIsVerified(w, r, c) {
|
||||
http.ServeFile(w, r, c.RSSFile)
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// tokenIsVerified verifies that a request is authorized. It returns a bool.
|
||||
func tokenIsVerified(w http.ResponseWriter, r *http.Request) bool {
|
||||
func tokenIsVerified(w http.ResponseWriter, r *http.Request, c *b.Config) bool {
|
||||
idToken := r.Header.Get("Authorization")
|
||||
if idToken == "" {
|
||||
log.Println("Authorization header missing")
|
||||
@ -16,7 +16,7 @@ func tokenIsVerified(w http.ResponseWriter, r *http.Request) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
client, err := b.NewClient()
|
||||
client, err := b.NewClient(c)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
Reference in New Issue
Block a user