go_firebase_service

package module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 9 Imported by: 0

README

firebase-service

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Claims = struct {
	UID      Claim
	UserIdDb Claim
	UserId   Claim
	AdminId  Claim
}{
	UID:      "UID",
	UserIdDb: "user-id-db",
	UserId:   "user-id",
	AdminId:  "admin-id",
}
View Source
var Roles = struct {
	SuperAdmin Role
	Admin      Role
	User       Role
	Key        string
}{
	SuperAdmin: "super-amin",
	Admin:      "admin",
	User:       "user",
	Key:        "role",
}

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Logger  appConfigLogger
	Options *option.ClientOption
}

AppConfig structure

type AppService

type AppService struct {
	*firebase.App
}

AppService structure

func NewFirebaseApp

func NewFirebaseApp(config AppConfig) AppService

NewFirebaseApp creates new firebase App instance

type AuthConfig

type AuthConfig struct {
	Logger authConfigLogger
	App    *firebase.App
}

type AuthErrorResponse

type AuthErrorResponse struct {
	Message   string `json:"message"`
	ErrorType int    `json:"error_type"`
}

AuthErrorResponse structure

type AuthService

type AuthService struct {
	*auth.Client
}

AuthService structure

func NewFirebaseAuthService

func NewFirebaseAuthService(config AuthConfig) AuthService

NewFirebaseAuthService creates new firebase service

func (*AuthService) Create

func (fb *AuthService) Create(
	userRequest AuthUser, setClaims ...func(claims claimsMap) claimsMap,
) (
	string, *AuthErrorResponse,
)

Create creates a new user with email and password

func (*AuthService) CreateAdmin

func (fb *AuthService) CreateAdmin(userRequest AuthUser) (string, *AuthErrorResponse)

CreateAdmin creates a new admin with email and password

func (*AuthService) CreateCustomToken

func (fb *AuthService) CreateCustomToken(ctx context.Context, uid string) (string, *AuthErrorResponse)

func (*AuthService) CreateUser

func (fb *AuthService) CreateUser(userRequest AuthUser) (string, *AuthErrorResponse)

CreateUser creates a new user with email and password

func (*AuthService) DisableUser

func (fb *AuthService) DisableUser(uid string, disable bool) *AuthErrorResponse

DisableUser true for disabled; false for enabled.

func (*AuthService) SetClaim

func (fb *AuthService) SetClaim(uid string, claims map[string]interface{}) *AuthErrorResponse

SetClaim set's claim to firebase user

func (*AuthService) UpdateEmailVerification

func (fb *AuthService) UpdateEmailVerification(uid string) *AuthErrorResponse

UpdateEmailVerification update firebase user email verify

func (*AuthService) UpdateFirebaseAdmin

func (fb *AuthService) UpdateFirebaseAdmin(UID string, newUserData, oldUserData AuthUser) *AuthErrorResponse

UpdateFirebaseAdmin handles the common operation to update admin in Firebase for OneStore Admin and Admin

func (*AuthService) VerifyToken

func (fb *AuthService) VerifyToken(idToken string) (*auth.Token, *AuthErrorResponse)

VerifyToken verify passed firebase id token

type AuthUser

type AuthUser struct {
	Password    string
	Role        string
	DisplayName *string
	Email       string
	AdminID     int64
	UserID      int64
}

type CMClientConfig

type CMClientConfig struct {
	Logger loggerCMClient
	App    *firebase.App
}

type CMClientService

type CMClientService struct {
	*messaging.Client
}

func NewFirebaseCMClient

func NewFirebaseCMClient(config CMClientConfig) CMClientService

NewFirebaseCMClient creates new firebase cloud messaging client

type Claim

type Claim string

Claim custom token claims

func (Claim) Name

func (r Claim) Name() string

func (Claim) ToString

func (r Claim) ToString() string

type Role

type Role string

Role roles of users

func (Role) ToString

func (r Role) ToString() string

type StoreClientConfig

type StoreClientConfig struct {
	Logger storeClientLogger
	App    *firebase.App
}

type StoreClientService

type StoreClientService struct {
	*firestore.Client
}

func NewFireStoreClient

func NewFireStoreClient(config StoreClientConfig) StoreClientService

NewFireStoreClient creates new firestore client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL