Documentation ¶
Index ¶
- Constants
- func Run() error
- type Account
- type Accounts
- func NewAccounts(actorID uint, username, mail, password, privateKey string) *Accounts
- func NewAccountsCreate(username, mail, password string) *Accounts
- func NewAccountsDelete(username, password string) *Accounts
- func NewAccountsID(id uint) *Accounts
- func NewEditPassword(username, password string) *Accounts
- func NewUsername(username string) *Accounts
- func NewVerify(username string) *Accounts
- func (a *Accounts) Create(publicKey string) error
- func (a *Accounts) Delete() error
- func (a *Accounts) EditEmail(mail string) error
- func (a *Accounts) EditPassword(new string) error
- func (a *Accounts) EditUsername(username string) error
- func (a *Accounts) GetAccountByUsername() (*Accounts, error)
- func (a *Accounts) GetPrivateKey() (string, error)
- func (a *Accounts) IsExist() bool
- func (a *Accounts) Verify(password string) (*Accounts, error)
Constants ¶
View Source
const ( AccountsTable = "accounts" ActorsTable = "actors" )
View Source
const (
UsernameAlreadyExists = "THE_USERNAME_ALREADY_EXISTS"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Account ¶
type Account interface { // IsExist Determine if the account exists. IsExist() bool // Create need to verify whether the username and email address have been registered or not, // and return an error if they have been registered. // publicKey is account auth public key not activitypub public key. Create(publicKey string) error // Delete Verify that the account is correct first, then delete the account by ID. Delete() error // EditUsername Edit username. EditUsername(username string) error // EditPassword Edit the password. EditPassword(newPassword string) error // EditEmail Editorial email. EditEmail(mail string) error // Verify that the account password is correct, used to verify when logging in or changing the password, // pass the password sent and then compare the password queried in the database. Verify(password string) (*Accounts, error) // GetPrivateKey When performing activitypub activities, // you need to obtain the private key for signing and other operations. GetPrivateKey() (string, error) GetAccountByUsername() (*Accounts, error) }
type Accounts ¶
type Accounts struct { gorm.Model // Username As the primary key of the database, it cannot be duplicated. Username string `gorm:"primaryKey;type:text;username;unique" validate:"required,min=4,max=16"` // Mail must ensure that the email is unique and properly formatted and cannot be empty. // When the user forgets the password, the user is required to provide an email which is unique. // Therefore, when registering, the user must provide an email. Mail string `gorm:"index;type:text;mail;unique" validate:"required,email"` // Password // The length of the password must be greater than 8 characters and // less than 24 characters, and must not contain spaces. Password string `gorm:"type:text;password" validate:"required,min=8,max=24"` // When creating a user, an actor needs to be created to record the basic information // of the user for compatibility with the ActivityPub protocol. // The ActorID field is the id of the actor and is used to associate the actor. ActorID uint `gorm:"type:bigint;actor_id"` // IsPrivate Set whether the account is private or not, private accounts are not displayed publicly. IsPrivate bool `gorm:"type:boolean;is_private"` // PrivateKey The private key corresponding to the Activitypub protocol is used // only for social activities and no other encryption is involved. PrivateKey string `gorm:"type:text;private_key"` }
func NewAccounts ¶
NewAccounts This constructor is needed to formally create a complete account in the Create Account method.
func NewAccountsCreate ¶
NewAccountsCreate Constructor for creating an account.
func NewAccountsDelete ¶
NewAccountsDelete Constructor for deleting an account.
func NewAccountsID ¶
NewAccountsID Constructing an account ID.
func NewEditPassword ¶
NewEditPassword Constructor for editing an account's password.
func NewUsername ¶
NewUsername constructor account's username.
func (*Accounts) EditPassword ¶
func (*Accounts) EditUsername ¶
func (*Accounts) GetAccountByUsername ¶
func (*Accounts) GetPrivateKey ¶
Click to show internal directories.
Click to hide internal directories.