app

package
v0.0.0-...-9e72f66 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExpiredToken represents message for expired token
	ErrExpiredToken = errors.New("token expired or invalid")
	// ErrUnauthorized represents message for unauthorized
	ErrUnauthorized = errors.New("unauthorized")
)
View Source
var (
	// ErrGenerateSchema represents message for generating schema
	ErrGenerateSchema = errors.New("an error occured while genarating schema")
	// ErrCreateSchema represents message for creating schema
	ErrCreateSchema = errors.New("an error occured while creating the schema and tables")
)

Functions

func CancelSubscription

func CancelSubscription(s db.Store, r *http.Request) (int, string)

func ChangeMasterPassword

func ChangeMasterPassword(s db.Store, user *model.User, newMasterPassword string) (*model.User, error)

ChangeMasterPassword updates the user with the new master password

func CreateCreditCard

func CreateCreditCard(s db.Store, dto *model.CreditCardDTO, schema string) (*model.CreditCard, error)

CreateCreditCard creates a new credit card and saves it to the store

func CreateEmail

func CreateEmail(s db.Store, dto *model.EmailDTO, schema string) (*model.Email, error)

CreateEmail creates a new bank account and saves it to the store

func CreateHash

func CreateHash(key string) string

CreateHash ...

func CreateLogin

func CreateLogin(s db.Store, dto *model.LoginDTO, schema string) (*model.Login, error)

CreateLogin creates a login and saves it to the store

func CreateLogins

func CreateLogins(s db.Store, dtos []model.LoginDTO, schema string) error

CreateLogins is needed for import

func CreateNote

func CreateNote(s db.Store, dto *model.NoteDTO, schema string) (*model.Note, error)

CreateNote creates a new note and saves it to the store

func CreateServer

func CreateServer(s db.Store, dto *model.ServerDTO, schema string) (*model.Server, error)

CreateServer creates a server and saves it to the store

func CreateSubscription

func CreateSubscription(s db.Store, r *http.Request) (int, string)

CreateSubscription creates a subscription and saves it to the store

func CreateToken

func CreateToken(user *model.User) (*model.TokenDetailsDTO, error)

CreateToken ...

func CreateUser

func CreateUser(s db.Store, userDTO *model.UserDTO) (*model.User, error)

CreateUser creates a user and saves it to the store

func Decrypt

func Decrypt(dataStr string, passphrase string) []byte

Decrypt ... TODO: Return error if decryption fails

func DecryptFile

func DecryptFile(filename string, passphrase string) []byte

DecryptFile ...

func DecryptJSON

func DecryptJSON(key string, encrypted []byte, v interface{}) error

DecryptJSON ...

func DecryptModel

func DecryptModel(rawModel interface{}) (interface{}, error)

DecryptModel decrypts struct pointer according to struct tags

func DecryptPayload

func DecryptPayload(key string, encrypted []byte) ([]byte, error)

DecryptPayload ...

func Encrypt

func Encrypt(dataStr string, passphrase string) []byte

Encrypt .. TODO: Return error if encryption fails

func EncryptFile

func EncryptFile(filename string, data []byte, passphrase string)

EncryptFile ...

func EncryptJSON

func EncryptJSON(key string, v interface{}) ([]byte, error)

EncryptJSON ...

func EncryptModel

func EncryptModel(rawModel interface{}) interface{}

EncryptModel encrypts struct pointer according to struct tags

func FallbackInsecureKey

func FallbackInsecureKey(length int) (string, error)

FallbackInsecureKey fallback method for sercure key

func FindIndex

func FindIndex(vs []string, t string) int

FindIndex ...

func GenerateSchema

func GenerateSchema(s db.Store, user *model.User) (*model.User, error)

GenerateSchema creates user schema and tables

func GenerateSecureKey

func GenerateSecureKey(length int) (string, error)

GenerateSecureKey generates a secure key width a given length

func GetBackupFiles

func GetBackupFiles() ([]os.FileInfo, error)

GetBackupFiles retrieves backup files

func GetMD5Hash

func GetMD5Hash(text []byte) string

GetMD5Hash ...

func MigrateSystemTables

func MigrateSystemTables(s db.Store)

MigrateSystemTables runs auto migration for the system models (Token and User), will only add missing fields won't delete/change current data in the store.

func MigrateUserTables

func MigrateUserTables(s db.Store, schema string) error

MigrateUserTables runs auto migration for user models in user schema, will only add missing fields won't delete/change current data in the store.

func NewBcrypt

func NewBcrypt(key []byte) string

NewBcrypt ...

func PayloadValidator

func PayloadValidator(model interface{}) error

PayloadValidator ...

func PaymentFailedSubscription

func PaymentFailedSubscription(s db.Store, r *http.Request) (int, string)

func PaymentSucceedSubscription

func PaymentSucceedSubscription(s db.Store, r *http.Request) (int, string)

func RandomMD5Hash

func RandomMD5Hash() string

RandomMD5Hash returns random md5 hash for unique conifrim links

func SendMail

func SendMail(name, email string, subject, bodyHTML string) error

SendMail is an helper to send mail all over the project

func TokenValid

func TokenValid(bearerToken string) (*jwt.Token, error)

TokenValid ...

func UpdateCreditCard

func UpdateCreditCard(s db.Store, creditCard *model.CreditCard, dto *model.CreditCardDTO, schema string) (*model.CreditCard, error)

UpdateCreditCard updates the credit card with the dto and applies the changes in the store

func UpdateEmail

func UpdateEmail(s db.Store, email *model.Email, dto *model.EmailDTO, schema string) (*model.Email, error)

UpdateEmail updates the account with the dto and applies the changes in the store

func UpdateLogin

func UpdateLogin(s db.Store, login *model.Login, dto *model.LoginDTO, schema string) (*model.Login, error)

UpdateLogin updates the login with the dto and applies the changes in the store

func UpdateNote

func UpdateNote(s db.Store, note *model.Note, dto *model.NoteDTO, schema string) (*model.Note, error)

UpdateNote updates the note with the dto and applies the changes in the store

func UpdateServer

func UpdateServer(s db.Store, server *model.Server, dto *model.ServerDTO, schema string) (*model.Server, error)

UpdateServer updates the server with the dto and applies the changes in the store

func UpdateSubscription

func UpdateSubscription(s db.Store, r *http.Request) (int, string)

func UpdateUser

func UpdateUser(s db.Store, user *model.User, userDTO *model.UserDTO, isAuthorized bool) (*model.User, error)

UpdateUser updates the user with the dto and applies the changes in the store

Types

This section is empty.

Jump to

Keyboard shortcuts

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