user

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUserAlreadyConfirmed is retgurned when a user account has been already confirmed.
	ErrUserAlreadyConfirmed = errors.New("Account already confirmed")
)

Functions

func Actions

func Actions(c echo.Context) error

Actions handles the different actions over a user.

func CheckEmailExist

func CheckEmailExist(email string) (bool, error)

CheckEmailExist returns true if emails exists

func Confirm

func Confirm(username string) error

Confirm confirms user.

func CreateAdminUser

func CreateAdminUser()

CreateAdminUser creates admin user.

func DeleteAllUsers

func DeleteAllUsers()

DeleteAllUsers will empty users bucket

func DeleteUser

func DeleteUser(c echo.Context) error

DeleteUser handle /DELETE request

func DeleteUsers

func DeleteUsers(c echo.Context) error

DeleteUsers handlers /DELETE

func GetActivities

func GetActivities(c echo.Context) error

GetActivities represents the feed displayed in the landing page for anonymous users.

func GetActivitiy

func GetActivitiy(c echo.Context) error

GetActivitiy represents the feed displayed in the landing page for logged in users.

func GetAvatar

func GetAvatar(c echo.Context) error

GetAvatar returns a user avatar.

func GetComments

func GetComments(c echo.Context) error

GetComments returns list comments by user with metadata.

func GetFollowers

func GetFollowers(c echo.Context) error

GetFollowers returns list of users following this user with metadata.

func GetFollowing

func GetFollowing(c echo.Context) error

GetFollowing returns list of followed users by this user with metadata.

func GetLikes

func GetLikes(c echo.Context) error

GetLikes returns list of likes samples with metadata.

func GetSubmissions

func GetSubmissions(c echo.Context) error

GetSubmissions returns list of submissions with metadata.

func GetUser

func GetUser(c echo.Context) error

GetUser handle /GET request

func GetUsers

func GetUsers(c echo.Context) error

GetUsers returns all users.

func HashAndSalt

func HashAndSalt(pwd []byte) string

HashAndSalt hash with a salt a password.

func PostUsers

func PostUsers(c echo.Context) error

PostUsers adds a new user.

func PutUser

func PutUser(c echo.Context) error

PutUser updates a given user.

func PutUsers

func PutUsers(c echo.Context) error

PutUsers bulk updates Users

func UpdateAvatar

func UpdateAvatar(c echo.Context) error

UpdateAvatar updates the users' avatar

func UpdateFollowingFollowersToLowerCase

func UpdateFollowingFollowersToLowerCase() error

func UpdateProfileCounts

func UpdateProfileCounts() error

Types

type Activity

type Activity struct {
	Timestamp *time.Time  `json:"timestamp,omitempty"`
	Type      string      `json:"type,omitempty"`
	Content   interface{} `json:"content,omitempty"`
}

Activity represents an event made by the user such as `upload`.

type Comment

type Comment struct {
	Timestamp *time.Time `json:"timestamp,omitempty"`
	Sha256    string     `json:"sha256,omitempty"`
	Body      string     `json:"body,omitempty"`
	ID        string     `json:"id,omitempty"`
}

type Submission

type Submission struct {
	Timestamp *time.Time `json:"timestamp,omitempty"`
	Sha256    string     `json:"sha256,omitempty"`
}

type User

type User struct {
	Email            string       `json:"email,omitempty"`
	Username         string       `json:"username,omitempty"`
	Password         string       `json:"password,omitempty"`
	Name             string       `json:"name,omitempty"`
	Location         string       `json:"location,omitempty"`
	URL              string       `json:"url,omitempty"`
	Bio              string       `json:"bio,omitempty"`
	Confirmed        bool         `json:"confirmed,omitempty"`
	MemberSince      *time.Time   `json:"member_since,omitempty"`
	LastSeen         *time.Time   `json:"last_seen,omitempty"`
	Admin            bool         `json:"admin,omitempty"`
	HasAvatar        bool         `json:"has_avatar,omitempty"`
	Following        []string     `json:"following,omitempty"`
	FollowingCount   int          `json:"following_count"`
	Followers        []string     `json:"followers,omitempty"`
	FollowersCount   int          `json:"followers_count"`
	Likes            []string     `json:"likes,omitempty"`
	LikesCount       int          `json:"likes_count"`
	Activities       []Activity   `json:"activities,omitempty"`
	Submissions      []Submission `json:"submissions"`
	SubmissionsCount int          `json:"submissions_count"`
	Comments         []Comment    `json:"comments,omitempty"`
	CommentsCount    int          `json:"comments_count"`
}

User represent a user.

func Create

func Create(username, password, email string) User

Create creates a new user

func GetAllUsers

func GetAllUsers(fields []string) ([]User, error)

GetAllUsers return all users (optional: selecting fields)

func GetByUsername

func GetByUsername(username string) (User, error)

GetByUsername return user document

func GetUserByEmail

func GetUserByEmail(email string) (User, error)

GetUserByEmail return a user document from email

func GetUserByUsernameFields

func GetUserByUsernameFields(fields []string, username string) (User, error)

GetUserByUsernameFields return user by username(optional: selecting fields)

func (*User) GenerateEmailConfirmationToken

func (u *User) GenerateEmailConfirmationToken() (string, error)

GenerateEmailConfirmationToken creates a JWT token for email confirmation.

func (*User) GenerateResetPasswordToken

func (u *User) GenerateResetPasswordToken() (string, error)

GenerateResetPasswordToken creates a JWT token for password change.

func (*User) NewActivity

func (u *User) NewActivity(activityType string, content map[string]string) Activity

NewActivity creates a new activity.

func (*User) Save

func (u *User) Save()

Save adds user to a database.

func (*User) UpdatePassword

func (u *User) UpdatePassword(newPassword string)

UpdatePassword creates a JWT token for email confirmation.

Jump to

Keyboard shortcuts

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