From 3722257deec99d03612e74272c00d9aefed85d1f Mon Sep 17 00:00:00 2001 From: PandaJW <5168pandayoyo@gmail.com> Date: Sun, 11 Aug 2024 13:40:56 +0800 Subject: [PATCH] prep pt2 --- database.go | 17 +++++++++-------- firebase.go | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/database.go b/database.go index 16621d6..bcb69ac 100644 --- a/database.go +++ b/database.go @@ -6,6 +6,7 @@ import ( "fmt" "log" "net/http" + "os" "strings" firebase "firebase.google.com/go" @@ -16,16 +17,16 @@ import ( var firebaseClient *db.Client func SessionCookie() (string, error) { - sessionCookieStore := goDotEnvVariable("SESSION_COOKIE_STORE") - if sessionCookieStore == "" { - return sessionCookieStore, fmt.Errorf("SESSION_COOKIE_STORE is not set in the environment variables") - } - - // sessionCookieStore, found := os.LookupEnv("COOKIESTORE") - // if !found { - // log.Fatalf("COOKIESTORE is not set in the environment variables") + // sessionCookieStore := goDotEnvVariable("SESSION_COOKIE_STORE") + // if sessionCookieStore == "" { + // return sessionCookieStore, fmt.Errorf("SESSION_COOKIE_STORE is not set in the environment variables") // } + sessionCookieStore, found := os.LookupEnv("COOKIESTORE") + if !found { + log.Fatalf("COOKIESTORE is not set in the environment variables") + } + return sessionCookieStore, nil } diff --git a/firebase.go b/firebase.go index 2a1ee59..5cdbe7d 100644 --- a/firebase.go +++ b/firebase.go @@ -30,17 +30,17 @@ func goDotEnvVariable(key string) string { func initializeFirebase() error { ctx := context.Background() - // databaseURL, found := os.LookupEnv("DATABASE_URL") - // if !found { - // log.Fatalf("DATABASE_URL is not set in the environment variables") - // } - // opt := option.WithCredentialsFile("edusync-7bd5e-firebase-adminsdk-x49uh-af084a6314.json") - - databaseURL := goDotEnvVariable("DATABASE_URL") - if databaseURL == "" { - return fmt.Errorf("DATABASE_URL is not set in the environment variables") + databaseURL, found := os.LookupEnv("DATABASE_URL") + if !found { + log.Fatalf("DATABASE_URL is not set in the environment variables") } - opt := option.WithCredentialsFile("edusync-test-firebase-adminsdk-hk5kl-9af0162b09.json") + opt := option.WithCredentialsFile("edusync-7bd5e-firebase-adminsdk-x49uh-af084a6314.json") + + // databaseURL := goDotEnvVariable("DATABASE_URL") + // if databaseURL == "" { + // return fmt.Errorf("DATABASE_URL is not set in the environment variables") + // } + // opt := option.WithCredentialsFile("edusync-test-firebase-adminsdk-hk5kl-9af0162b09.json") conf := &firebase.Config{DatabaseURL: databaseURL}