Documentation
¶
Index ¶
- func Base6424(src string) string
- func GenerateString(n int) string
- func GenerateToken(username string) string
- type Client
- func (cl *Client) Authenticate(username, password string, asAdmin bool) bool
- func (cl *Client) CheckAdmin(username string) bool
- func (cl *Client) ClearCookie(name string)
- func (cl *Client) ClearSession()
- func (cl *Client) GetConfig(key string) string
- func (cl *Client) GetCookie(name string) string
- func (cl *Client) GetFile(fn string) []byte
- func (cl *Client) InvalidateAdminSessions(username string)
- func (cl *Client) InvalidateSessions(username string)
- func (cl *Client) IsAdmin() bool
- func (cl *Client) IsAuthenticated(asAdmin bool) bool
- func (cl *Client) LoadTemplate(fn string, data any) []byte
- func (cl *Client) LoadTemplates(files []string, data any) []byte
- func (cl *Client) PutFile(fn string, data []byte)
- func (cl *Client) Query(sql string, args ...any) (pgx.Rows, error)
- func (cl *Client) QueryRow(sql string, args ...any) pgx.Row
- func (cl *Client) Redirect(url string, code int)
- func (cl *Client) SetCookie(name, value string)
- func (cl *Client) SetHeader(name, value string)
- func (cl *Client) UpdateAdminSession(username string)
- func (cl *Client) UpdateSession(username string)
- func (cl *Client) Write(s string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateToken ¶ added in v0.8.0
GenerateToken creates a token for the user session.
Types ¶
type Client ¶
type Client struct {
// Client for S3 operations.
*s3.Client
// W is the HTTP response writer.
W http.ResponseWriter
// R is the HTTP request.
R *http.Request
// Conn is the PostgreSQL connection.
Conn *pgx.Conn
}
Client is a wrapper around the S3 client and authentication tokens.
func NewClient ¶
func NewClient(w http.ResponseWriter, r *http.Request) *Client
NewClient creates a client.
func (*Client) Authenticate ¶ added in v0.8.0
Authenticate checks the user's password and updates the session if valid, and the user is an admin.
func (*Client) CheckAdmin ¶ added in v0.11.0
CheckAdmin checks if a user is an admin.
func (*Client) ClearCookie ¶ added in v0.4.0
ClearCookie in HTTP response.
func (*Client) ClearSession ¶ added in v0.16.0
func (cl *Client) ClearSession()
ClearSession removes the session cookies of the current user.
func (*Client) InvalidateAdminSessions ¶ added in v0.17.0
InvalidateAdminSessions removes all admin sessions for a user.
func (*Client) InvalidateSessions ¶ added in v0.17.0
InvalidateSessions removes all sessions for a user.
func (*Client) IsAuthenticated ¶ added in v0.8.0
IsAuthenticated checks if the user is logged in.
func (*Client) LoadTemplate ¶ added in v0.18.0
LoadTemplate from S3 storage.
func (*Client) LoadTemplates ¶ added in v0.19.2
LoadTemplates from S3 storage.
func (*Client) UpdateAdminSession ¶ added in v0.19.2
UpdateAdminSession by extending the expiry.
func (*Client) UpdateSession ¶ added in v0.19.2
UpdateSession for a user by extending the expiry.