auth

package
v0.0.0-...-6b5a9da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

templ: version: v0.2.778

Index

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

Functions

func SetAuthContext

func SetAuthContext(ctx context.Context, auth_ctx AuthContext) context.Context

func SetAuthCookie

func SetAuthCookie(w http.ResponseWriter, user_cookie *AuthCookie)

func SignInMain

func SignInMain(error_message string, redirect_to string) templ.Component

func SignInPage

func SignInPage(user *state.User, error_message string, redirect_to string) templ.Component

Types

type AuthContext

type AuthContext struct {
	User state.User
}

func GetAuthContext

func GetAuthContext(ctx context.Context) AuthContext

func NewAuthContext

func NewAuthContext(user state.User) AuthContext

type AuthCookie

type AuthCookie struct {
	UserID   int64
	UserRole state.UserRole
}

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

type AuthMiddlewareHandler struct {
	Handler http.Handler
	Queries *state.Queries
}

func NewAuthMiddlewareHandler

func NewAuthMiddlewareHandler(handler http.Handler, queries *state.Queries) *AuthMiddlewareHandler

func (*AuthMiddlewareHandler) ServeHTTP

type UserSignInPageHandler

type UserSignInPageHandler struct {
	// contains filtered or unexported fields
}

func NewUserSignInHandler

func NewUserSignInHandler(queries *state.Queries) *UserSignInPageHandler

func (*UserSignInPageHandler) ServeHTTP

type UserSignInSubmitHandler

type UserSignInSubmitHandler struct {
	Queries  *state.Queries
	Commands *commands.Commands
}

func NewUserSignInSubmitHandler

func NewUserSignInSubmitHandler(queries *state.Queries, commands *commands.Commands) *UserSignInSubmitHandler

func (*UserSignInSubmitHandler) ServeHTTP

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL