Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicAuth ¶
func BasicAuth(s Session) http.HandlerFunc
BasicAuth provides basic authentication.
func Login ¶
func Login(s Session) http.HandlerFunc
Login takes a user credentials and authenticates it.
func LoginGoogle ¶
func LoginGoogle(s Session) http.HandlerFunc
LoginGoogle redirects the user to the google oauth2.
func Logout ¶
func Logout(s Session) http.HandlerFunc
Logout logs the user out from the session and removes cookies.
func OAuth2Google ¶
func OAuth2Google(s Session) http.HandlerFunc
OAuth2Google executes the oauth2 login with Google.
Types ¶
type Session ¶
type Session interface { AlreadyLoggedIn(ctx context.Context, r *http.Request) bool Login(ctx context.Context, w http.ResponseWriter, r *http.Request, email, password string) error LoginOAuth(ctx context.Context, w http.ResponseWriter, r *http.Request, email string) error Logout(ctx context.Context, w http.ResponseWriter, r *http.Request) error }
Session provides auth operations.
type User ¶
type User struct { ID string `json:"id"` CartID string `json:"cart_id" db:"cart_id"` Username string `json:"username"` Email string `json:"email" validate:"email,required"` Password string `json:"password" validate:"required,min=6"` VerifiedEmail bool `json:"-" db:"verified_email"` }
User represents a customer trying to log in.
Click to show internal directories.
Click to hide internal directories.