Documentation ¶
Index ¶
- Variables
- func AddSession(username string) (string, error)
- func CanProceed(rq *http.Request, route string) bool
- func Count() (i uint64)
- func CredentialsOK(username, password string) bool
- func DeleteUser(name string) error
- func HasAnyAdmins() bool
- func HasUsername(username string) bool
- func InitUserDatabase()
- func IsValidUsername(username string) bool
- func ListUsersWithGroup(group string) []string
- func LoginDataHTTP(w http.ResponseWriter, username, password string) error
- func LogoutFromRequest(w http.ResponseWriter, rq *http.Request)
- func ReadUsersFromFilesystem()
- func Register(username, password, group, source string, force bool) error
- func SaveUserDatabase() error
- func TelegramAuthParamsAreValid(params map[string][]string) bool
- func UsersInGroups() (admins []string, moderators []string, editors []string, readers []string)
- func ValidGroup(group string) bool
- func ValidSource(source string) bool
- func YieldUsers() chan *User
- type User
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownUsername = errors.New("unknown username") ErrWrongPassword = errors.New("wrong password") )
Functions ¶
func AddSession ¶
AddSession saves a session for `username` and returns a token to use.
func CanProceed ¶
CanProceed returns `true` if the user in `rq` has enough rights to access `route`.
func CredentialsOK ¶
CredentialsOK checks whether a correct user-password pair is provided
func DeleteUser ¶
DeleteUser removes a user by one's name and saves user database.
func HasAnyAdmins ¶
func HasAnyAdmins() bool
func HasUsername ¶
HasUsername checks whether the desired user exists
func InitUserDatabase ¶
func InitUserDatabase()
InitUserDatabase loads users, if necessary. Call it during initialization.
func IsValidUsername ¶
IsValidUsername checks if the given username is valid.
func ListUsersWithGroup ¶
ListUsersWithGroup returns a slice with users of desired group.
func LoginDataHTTP ¶
func LoginDataHTTP(w http.ResponseWriter, username, password string) error
LoginDataHTTP logs such user in and returns string representation of an error if there is any.
The HTTP parameters are used for setting header status (bad request, if it is bad) and saving a cookie.
func LogoutFromRequest ¶
func LogoutFromRequest(w http.ResponseWriter, rq *http.Request)
LogoutFromRequest logs the user in `rq` out and rewrites the cookie in `w`.
func ReadUsersFromFilesystem ¶
func ReadUsersFromFilesystem()
ReadUsersFromFilesystem reads all user information from filesystem and stores it internally.
func SaveUserDatabase ¶
func SaveUserDatabase() error
SaveUserDatabase stores current user credentials into JSON file by configured path.
func TelegramAuthParamsAreValid ¶
TelegramAuthParamsAreValid is true if the given params are ok.
func UsersInGroups ¶
func ValidGroup ¶
ValidGroup checks whether provided user group name exists.
func ValidSource ¶
ValidSource checks whether provided user source name exists.
func YieldUsers ¶
func YieldUsers() chan *User
YieldUsers creates a channel which iterates existing users.
Types ¶
type User ¶
type User struct { // Name is a username. It must follow hypha naming rules. Name string `json:"name"` Group string `json:"group"` Password string `json:"hashed_password"` RegisteredAt time.Time `json:"registered_on"` // Source is where the user from. Valid values: local, telegram. Source string `json:"source"` sync.RWMutex }
User contains information about a given user required for identification.
func FromRequest ¶
FromRequest returns user from `rq`. If there is no user, an anon user is returned instead.
func WikimindUser ¶
func WikimindUser() *User
WikimindUser constructs the wikimind user, which is to be used for automated wiki edits and has admin privileges.
func (*User) CanProceed ¶
CanProceed checks whether user has rights to visit the provided path (and perform an action).
func (*User) ChangePassword ¶
Sets a new password for the user.
func (*User) ShowLockMaybe ¶
ShowLockMaybe redirects to the lock page if the user is anon and the wiki has been configured to use the lock. It returns true if the user was redirected.