Documentation ¶
Overview ¶
templ: version: v0.2.778
Index ¶
- Constants
- Variables
- func SetAuthContext(ctx context.Context, auth_ctx AuthContext) context.Context
- func SetAuthCookie(w http.ResponseWriter, user_cookie *AuthCookie)
- func SignInMain(error_message string, redirect_to string) templ.Component
- func SignInPage(user *state.User, error_message string, redirect_to string) templ.Component
- type AuthContext
- type AuthCookie
- type AuthMiddlewareHandler
- type UserSignInPageHandler
- type UserSignInSubmitHandler
- type UserSignOutHandler
- type UserSignUpPageHandler
Constants ¶
View Source
const AuthContextKeyUser app_ctx.ContextKey = "user"
View Source
const AuthCookieRoleName = "baker-news_user-role"
View Source
const AuthCookieUserIDName = "baker-news_user-id"
View Source
const CookieExpirationDuration = 30 * 24 * time.Hour
Variables ¶
View Source
var GuestCookie = NewAuthCookie(state.UserGuest.ID, state.UserRoleGuest)
Functions ¶
func SetAuthContext ¶
func SetAuthContext(ctx context.Context, auth_ctx AuthContext) context.Context
func SetAuthCookie ¶
func SetAuthCookie(w http.ResponseWriter, user_cookie *AuthCookie)
Types ¶
type AuthContext ¶
func GetAuthContext ¶
func GetAuthContext(ctx context.Context) AuthContext
func NewAuthContext ¶
func NewAuthContext(user state.User) AuthContext
type AuthCookie ¶
func NewAuthCookie ¶
func NewAuthCookie(user_id int64, user_role state.UserRole) AuthCookie
func ParseAuthCookie ¶
func ParseAuthCookie(r *http.Request) (AuthCookie, bool, error)
func (AuthCookie) IsGuest ¶
func (c AuthCookie) IsGuest() bool
func (AuthCookie) IsUser ¶
func (c AuthCookie) IsUser() bool
type AuthMiddlewareHandler ¶
func NewAuthMiddlewareHandler ¶
func NewAuthMiddlewareHandler(handler http.Handler, queries *state.Queries) *AuthMiddlewareHandler
func (*AuthMiddlewareHandler) ServeHTTP ¶
func (m *AuthMiddlewareHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type UserSignInPageHandler ¶
type UserSignInPageHandler struct {
// contains filtered or unexported fields
}
func NewUserSignInHandler ¶
func NewUserSignInHandler(queries *state.Queries) *UserSignInPageHandler
func (*UserSignInPageHandler) ServeHTTP ¶
func (h *UserSignInPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type UserSignInSubmitHandler ¶
func NewUserSignInSubmitHandler ¶
func NewUserSignInSubmitHandler(queries *state.Queries, commands *commands.Commands) *UserSignInSubmitHandler
func (*UserSignInSubmitHandler) ServeHTTP ¶
func (h *UserSignInSubmitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type UserSignOutHandler ¶
type UserSignOutHandler struct { }
func NewUserSignOutHandler ¶
func NewUserSignOutHandler(queries *state.Queries) *UserSignOutHandler
func (*UserSignOutHandler) ServeHTTP ¶
func (h *UserSignOutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type UserSignUpPageHandler ¶
type UserSignUpPageHandler struct {
// contains filtered or unexported fields
}
func NewUserSignUpHandler ¶
func NewUserSignUpHandler(queries *state.Queries) *UserSignUpPageHandler
Click to show internal directories.
Click to hide internal directories.