Documentation
¶
Index ¶
- Constants
- type Error
- type FlarumClient
- func (fc FlarumClient) ActivateUser(userId string) error
- func (fc FlarumClient) DeactivateUser(userId string) error
- func (fc FlarumClient) DeleteUser(userId string) error
- func (fc FlarumClient) GetUserByUsername(username string) (user map[string]interface{}, err error)
- func (fc FlarumClient) LogIn(username string, password string) (token string, userId string, err error)
- func (fc FlarumClient) SignUp(username string, email string, password string) error
- func (fc FlarumClient) UpdateUserAttribute(userId string, attribute string, value string) error
- type RequestType
Constants ¶
View Source
const COOKIE_REMEMBER_ME = "flarum_remember"
View Source
const COOKIE_SESSION = "flarum_session"
View Source
const DAYS_MULTIPLIER = 60 * 60 * 24
View Source
const FORUM_API_SUFFIX = "/api"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FlarumClient ¶
type FlarumClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(url string, token string, maxAge int) *FlarumClient
- Creates a new client for the Flarum forum. Requires:
- Forum URL: without /api suffix and without trailing slash. eg. http://myforum.example.com
- Token: The API token that you set in your `_api_keys` table
- maxAge: Number of days for the cookie to be valid
func (FlarumClient) ActivateUser ¶
func (fc FlarumClient) ActivateUser(userId string) error
func (FlarumClient) DeactivateUser ¶
func (fc FlarumClient) DeactivateUser(userId string) error
func (FlarumClient) DeleteUser ¶
func (fc FlarumClient) DeleteUser(userId string) error
DeleteUser removes a user form the database. This is action cannot be undone!
func (FlarumClient) GetUserByUsername ¶
func (fc FlarumClient) GetUserByUsername(username string) (user map[string]interface{}, err error)
GetUserByUsername fetches the user data by a given userId
func (FlarumClient) LogIn ¶
func (fc FlarumClient) LogIn(username string, password string) (token string, userId string, err error)
LogIn creates a RememberMe token that can be added as a cookie to authenticate in Flarum forum
func (FlarumClient) SignUp ¶
func (fc FlarumClient) SignUp(username string, email string, password string) error
SignUp creates a new account in Flarum with the provided username, email and password Password needs to be at least 8 characters long
func (FlarumClient) UpdateUserAttribute ¶
func (fc FlarumClient) UpdateUserAttribute(userId string, attribute string, value string) error
UpdateUserBio update user field for a given attribute key and value
Source Files
¶
Click to show internal directories.
Click to hide internal directories.