Documentation ¶
Index ¶
- Variables
- func AddTeammate(collection *Collection, input TeammateT) error
- func ChangePassword(user *User, currentPassword string, password string) error
- func ChangePasswordForce(user *User, password string) error
- func ChangePasswordWithResetKey(user *User, resetKey, password string) error
- func CheckAuthToken(tokenID string) (uint64, error)
- func CollectionCreateAccessCheck(user *User, loggedInUser *User) error
- func CollectionReadAccessCheck(collection *Collection, user *User) error
- func CollectionWriteAccessCheck(collection *Collection, user *User) error
- func CreatePageview(userAgent string, input CreatePageviewInputT) error
- func CreateSession(userAgent string, remoteAddr string, input CreateSessionInputT) (string, error)
- func DeleteAuthToken(tokenID string) error
- func DeleteCollection(collection *Collection) error
- func DeleteCollectionShard(collection *Collection, shardID string) error
- func DeleteUser(user *User, password string) error
- func DeleteUserByAdmin(name string) error
- func GetCollectionData(collection *Collection, input *CollectionDataInputT) (*db.CollectionDataT, error)
- func GetCollectionShards(collection *Collection) ([]db.ShardDataT, error)
- func GetCollectionStatData(collection *Collection, input *CollectionDataInputT) (*db.CollectionStatDataT, error)
- func GetPageviews(collection *Collection, sessionKey string) ([]*db.PageviewDataT, error)
- func GetSessions(collection *Collection, input *CollectionDataInputT) ([]*db.SessionDataT, error)
- func RemoveTeammate(collection *Collection, email string) error
- func RunBackup(backupID string) error
- func SeedCollection(from time.Time, to time.Time, collectionID string, n int) error
- func SendResetPassword(user *User) error
- func SendVerifyEmail(user *User) error
- func UpdateCollection(collection *Collection, name string) error
- func UpdateSession(userAgent string, CollectionID string, sessionKey string) error
- func UpdateUser(name string, input *UserUpdateT) error
- func VerifyEmail(user *User, verificationKey string) error
- type AuthToken
- type Backup
- type Collection
- type CollectionDataInputT
- type CollectionInfoT
- type CollectionSummaryOptions
- type CollectionSummaryT
- type CreatePageviewInputT
- type CreateSessionInputT
- type CreateUserT
- type Error
- type TeammateT
- type User
- func CreateAuthToken(nameOrEmail string, password string) (string, *User, error)
- func CreateUser(input *CreateUserT) (*User, error)
- func GetUserByEmail(email string) (*User, error)
- func GetUserByID(ID uint64) (*User, error)
- func GetUserByName(name string) (*User, error)
- func RegisterUser(input *CreateUserT) (*User, error)
- type UserInfoT
- type UserUpdateT
Constants ¶
This section is empty.
Variables ¶
var ( ErrRegistrationDisabled = &Error{"Registration disabled", 403, "", ""} ErrInvalidEmail = &Error{"Invalid email", 400, "", ""} ErrInvalidUsername = &Error{"Invalid username", 400, "", ""} ErrInvalidCollectionName = &Error{"Invalid collection name", 400, "", ""} ErrPasswordNotMatch = &Error{"Password not match", 403, "", ""} ErrPasswordTooShort = &Error{"Password too short", 400, "", ""} ErrPasswordChangeDisabled = &Error{"Password change disabled for this account", 403, "", ""} ErrUserNotExist = &Error{"User not exist", 404, "", ""} ErrUserNameExist = &Error{"User Name exist", 403, "", ""} ErrUserEmailExist = &Error{"User Email exist", 403, "", ""} ErrUserDeletionDisabled = &Error{"User deletion disabled for this account", 403, "", ""} ErrUserIsTheLastAdmin = &Error{"User is the last admin", 403, "", ""} ErrAccessDenied = &Error{"Access denied", 403, "", ""} ErrInputDecodeFailed = &Error{"Input decode failed", 400, "", ""} ErrAuthtokenNotExist = &Error{"Authtoken not exist", 403, "", ""} ErrAuthtokenExpired = &Error{"Authtoken expired", 403, "", ""} ErrDB = &Error{"DB error", 500, "", ""} ErrBotsDontMatter = &Error{"Bots don't matter", 403, "", ""} ErrCollectionNotExist = &Error{"Collection not exist", 404, "", ""} ErrCollectionLimitExceeded = &Error{"Collection limit exceeded", 403, "", ""} ErrCollectionNameExist = &Error{"Collection name exists", 403, "", ""} ErrSessionNotExist = &Error{"Session not exist", 404, "", ""} ErrTeammateExist = &Error{"Teammate exist", 403, "", ""} ErrBackupNotExist = &Error{"Backup not exist", 404, "", ""} ErrEmailSending = &Error{"Can't send email", 500, "", ""} ErrEmailExpired = &Error{"Email expired", 403, "", ""} )
The possible errors
Functions ¶
func AddTeammate ¶
func AddTeammate(collection *Collection, input TeammateT) error
AddTeammate adds a teammate to the collection
func ChangePassword ¶
ChangePassword change a user's password when the password match
func ChangePasswordForce ¶
ChangePasswordForce change a user's password
func ChangePasswordWithResetKey ¶
ChangePasswordWithResetKey changes the user's password with a resetKey
func CheckAuthToken ¶
CheckAuthToken check whether the AuthToken is valid
func CollectionCreateAccessCheck ¶
CollectionCreateAccessCheck checks the create access
func CollectionReadAccessCheck ¶
func CollectionReadAccessCheck(collection *Collection, user *User) error
CollectionReadAccessCheck checks the read access
func CollectionWriteAccessCheck ¶
func CollectionWriteAccessCheck(collection *Collection, user *User) error
CollectionWriteAccessCheck checks the write access
func CreatePageview ¶
func CreatePageview(userAgent string, input CreatePageviewInputT) error
CreatePageview creates a pageview
func CreateSession ¶
func CreateSession(userAgent string, remoteAddr string, input CreateSessionInputT) (string, error)
CreateSession creates a session
func DeleteAuthToken ¶
DeleteAuthToken deletes an AuthToken
func DeleteCollection ¶
func DeleteCollection(collection *Collection) error
DeleteCollection deletes the collection
func DeleteCollectionShard ¶
func DeleteCollectionShard(collection *Collection, shardID string) error
DeleteCollectionShard deletes a shard
func DeleteUser ¶
DeleteUser deletes a user when the password patch
func DeleteUserByAdmin ¶
DeleteUserByAdmin deletes a user by Admin
func GetCollectionData ¶
func GetCollectionData(collection *Collection, input *CollectionDataInputT) (*db.CollectionDataT, error)
GetCollectionData returns the collection data
func GetCollectionShards ¶
func GetCollectionShards(collection *Collection) ([]db.ShardDataT, error)
GetCollectionShards return the collection shards
func GetCollectionStatData ¶
func GetCollectionStatData(collection *Collection, input *CollectionDataInputT) (*db.CollectionStatDataT, error)
GetCollectionStatData return the collection stats
func GetPageviews ¶
func GetPageviews(collection *Collection, sessionKey string) ([]*db.PageviewDataT, error)
GetPageviews return the pageviews for the collection
func GetSessions ¶
func GetSessions(collection *Collection, input *CollectionDataInputT) ([]*db.SessionDataT, error)
GetSessions return the collection's sessions
func RemoveTeammate ¶
func RemoveTeammate(collection *Collection, email string) error
RemoveTeammate removes the teammate from the collection
func SeedCollection ¶
SeedCollection seed a collection with n sessions
func SendResetPassword ¶
SendResetPassword sends an email to change user's password
func SendVerifyEmail ¶
SendVerifyEmail sends an email verify email to a user
func UpdateCollection ¶
func UpdateCollection(collection *Collection, name string) error
UpdateCollection updates the collection's name
func UpdateSession ¶
UpdateSession updates the session.End field
func UpdateUser ¶
func UpdateUser(name string, input *UserUpdateT) error
UpdateUser updates a user with UserUpdateT struct
func VerifyEmail ¶
VerifyEmail verifies the user email address with the verificationKey
Types ¶
type Collection ¶
type Collection = db.Collection
Collection is the db's collection struct
func CreateCollection ¶
func CreateCollection(ownerID uint64, name string) (*Collection, error)
CreateCollection creates a collection
func CreateCollectionByID ¶
func CreateCollectionByID(id string, name string, username string) (*Collection, error)
CreateCollectionByID creates a collection with a fixed ID
func GetCollection ¶
func GetCollection(id string) (*Collection, error)
GetCollection fetch a collection by ID
func GetCollectionByName ¶
func GetCollectionByName(user *db.User, name string) (*Collection, error)
GetCollectionByName fetch a collection by name
type CollectionDataInputT ¶
type CollectionDataInputT = db.CollectionDataInputT
CollectionDataInputT is the db's collectionDataInputT struct
type CollectionInfoT ¶
type CollectionInfoT struct { ID string `json:"id"` Name string `json:"name"` OwnerName string `json:"owner_name"` Created int64 `json:"created"` TeammateCount int `json:"teammate_count"` }
CollectionInfoT is struct for clients, stores the user information
func GetCollections ¶
func GetCollections() ([]CollectionInfoT, error)
GetCollections returns all collection
type CollectionSummaryOptions ¶
type CollectionSummaryOptions = db.CollectionSummaryOptions
CollectionSummaryOptions contains options for the db.GetCollectionSummary function
type CollectionSummaryT ¶
type CollectionSummaryT struct { ID string `json:"id"` User string `json:"user"` Name string `json:"name"` db.CollectionSummary }
CollectionSummaryT the struct for the Collection's summary
func GetCollectionSummariesByUserID ¶
func GetCollectionSummariesByUserID(ID uint64, readerID uint64, options CollectionSummaryOptions) ([]CollectionSummaryT, error)
GetCollectionSummariesByUserID returns the collection summaries for the user
type CreatePageviewInputT ¶
CreatePageviewInputT is the input for the CreatePageView
type CreateSessionInputT ¶
type CreateSessionInputT struct { CollectionID string Hostname string BrowserLanguage string ScreenResolution string WindowResolution string DeviceType string Referrer string }
CreateSessionInputT is the struct for creating a session
type CreateUserT ¶
type CreateUserT struct { Email string `json:"email"` Name string `json:"name"` Password string `json:"password"` }
CreateUserT is a struct for the clients to creating a user
type Error ¶
Error is the Extended error struct
func (*Error) HTTPMessage ¶
HTTPMessage returns the default HTTP error message
type TeammateT ¶
type TeammateT struct {
Email string `json:"email"`
}
TeammateT contains the teammates information for the client
func GetCollectionTeammates ¶
func GetCollectionTeammates(collection *Collection) ([]TeammateT, error)
GetCollectionTeammates returns the teammates emails
type User ¶
User is the the database user struct
func CreateAuthToken ¶
CreateAuthToken creates an AuthToken
func GetUserByEmail ¶
GetUserByEmail fetch an user by the user's email
func GetUserByID ¶
GetUserByID fetch an user by the user's email
func GetUserByName ¶
GetUserByName fetch an user by the user's name
func RegisterUser ¶
func RegisterUser(input *CreateUserT) (*User, error)
RegisterUser register an user by the user
type UserInfoT ¶
type UserInfoT struct { ID uint64 `json:"id"` Email string `json:"email"` Name string `json:"name"` Created int64 `json:"created"` IsAdmin bool `json:"is_admin"` DisablePwChange bool `json:"disable_pw_change"` LimitCollections bool `json:"limit_collections"` CollectionLimit uint32 `json:"collection_limit"` DisableUserDeletion bool `json:"disable_user_deletion"` EmailVerified bool `json:"email_verified"` CollectionCount int `json:"collection_count"` }
UserInfoT is struct for clients, stores the user information
func GetUserInfo ¶
GetUserInfo fetch an user by the user's email
type UserUpdateT ¶
type UserUpdateT struct { Name string `json:"name"` Email string `json:"email"` Password string `json:"password"` IsAdmin bool `json:"is_admin"` DisablePwChange bool `json:"disable_pw_change"` LimitCollections bool `json:"limit_collections"` CollectionLimit uint32 `json:"collection_limit"` DisableUserDeletion bool `json:"disable_user_deletion"` EmailVerified bool `json:"email_verified"` }
UserUpdateT is the struct for updating a user