migrating repo from old host server

This commit is contained in:
KS Jannette
2026-08-22 18:58:55 -04:00
commit 4968d7f575
153 changed files with 20009 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
package firebase
import (
"context"
"fmt"
"sync"
fb "firebase.google.com/go/v4"
"firebase.google.com/go/v4/auth"
"google.golang.org/api/option"
)
var ( //nolint:gochecknoglobals
authClient *auth.Client //nolint:gochecknoglobals
once sync.Once //nolint:gochecknoglobals
errInit error //nolint:gochecknoglobals
)
func Init(projectID string) error {
once.Do(func() {
ctx := context.Background()
var app *fb.App
var err error
if projectID != "" {
cfg := &fb.Config{ProjectID: projectID}
app, err = fb.NewApp(ctx, cfg, option.WithoutAuthentication())
} else {
app, err = fb.NewApp(ctx, nil)
}
if err != nil {
errInit = fmt.Errorf("initialize firebase app: %w", err)
return
}
authClient, err = app.Auth(ctx)
if err != nil {
errInit = fmt.Errorf("initialize firebase auth: %w", err)
return
}
})
return errInit
}
func Auth() *auth.Client {
return authClient
}

View File

@@ -0,0 +1,22 @@
package firebase
import (
"context"
"fmt"
"firebase.google.com/go/v4/auth"
)
// SetUserDisabled updates the Firebase user record's disabled flag.
func SetUserDisabled(ctx context.Context, uid string, disabled bool) error {
if authClient == nil {
return fmt.Errorf("firebase auth not initialized") //nolint:err113
}
if uid == "" {
return nil
}
params := (&auth.UserToUpdate{}).Disabled(disabled)
_, err := authClient.UpdateUser(ctx, uid, params)
return err
}