package
2.0.3+incompatible
Repository: https://github.com/zew/go-questionnaire.git
Documentation: pkg.go.dev
# Packages
Package shuffler creates slices of integers random, but reproducible; based on the ID of the user; classes of users see the same random order each time they visit; each page has a different randomization of appropriate length.
# Functions
AddTestLogin adds a systemtest login.
ChangePassword takes values from request.Form and tries change the user's password.
ChangePasswordPrimitiveCoreH has *no* outer HTML scaffold - for more, see ChangePasswordPrimitive.
ChangePasswordPrimitiveH has outer HTML scaffold - for more, see ChangePasswordPrimitive.
ComputeMD5Password is deliberately not a method.
CreateAnonymousIDCoreH has *no* outer HTML scaffold - for more, see CreateAnonymousID seems unused.
CreateAnonymousIDH has outer HTML scaffold - for more, see CreateAnonymousID.
Example writes a single login to file, to be extended or adapted.
FormToken returns a form token.
FromSession loads a login from session; second return value contains 'is set'.
GenerateHashesH is a admin UI to create login hashes for specific survey and user profile.
GenerateHashIDs encodes integer IDs into a kind of base64 encoded string.
GeneratePassword creates a password of requested length.
GeneratePasswordH is a convenience func to generate passwords via http request.
GeneratePwFromChars uses chars to create a password of requested length.
Get provides access to the logins data.
HashIDDecodeFirst turns a string into a slice of integers and returns the first integer.
IsFound checks the error argument, if it says user found - but wrong password.
Load reads from a JSON file.
LoadH is a convenience func to reload logins via http request.
LoggedInCheck checks, whether as user is logged in, and checks whether he has the required roles; l is always initialized and never nil.
LoginByHash first checks for direct login; extra short and preconfigured in config.json; last part of the path - moved into h;
LoginByHash then takes request values "u" and hash "h" - and not any password; it checks the hash against the values except "h"; any other request parameters are sorted and included into the hashing check; extended by loginsT.Salt.
LoginPrimitiveCoreH has *no* outer HTML scaffold - for more, see loginPrimitive.
LoginPrimitiveH has outer HTML scaffold - for more, see loginPrimitive.
LoginURL returns a URL plus a query fragment,.
LoginWithoutID creates a hash ID and forwards to direct login /d - LoginByHashID
the user ID is created from unix time plus some in-memory counter
it's called permalink in subsequent logic
it's related to CreateAnonymousID but the ID comes from an internal timestamp plus atomic counter, it is not created from coarse personal attributes (such as first letter of father's name).
LogoutH is a convenience handler to logout via http request.
Md5Str computes the MD5 hash of a byte slice; MD5 consists 16 bytes of number.
OuterHTMLPost wraps parameter content into a HTML 5 scaffold and a form tag.
Query returns a query fragment, using the expected param names u, sid, wid, h See also userAttrs{}.
ReloadH removes the existing questioniare from the session, reading it anew from the questionnaire template JSON file, allowing to start anew.
SaveH is a convenience func to save logins file via http request.
ShufflesToCSV computes random but deterministic shufflings for usage outside the app.
ValidateAndLogin takes request values "username" and "password".
ValidateFormToken checks tokens against current hour - back to n previous hours.
# Variables
LgnsPath is obtained by ENV variable or command line flag in main package.
# Structs
LoginT must be exported, *not* because we need to pass a type to sessx.GetObject
loginIntf, ok := sess.EffectiveObj(key)
if !ok {
// log.Printf("key %v for LoginT{} is not in session", key)
return &LoginT{}, false, nil
}
l, ok := loginIntf.(LoginT)
if !ok {
return &LoginT{}, false, fmt.Errorf("key %v for LoginT{} does not point to lgn.LoginT{} - but to %T", key, loginIntf)
}
but because we need to declare variables of this type
type TplDataT struct {
..