auth

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionCtxKey = "session"
)

Variables

This section is empty.

Functions

func NewGetSessionError

func NewGetSessionError() *rest.Error

func NewMiddleware

func NewMiddleware(s rest.Server, store Store) func(next http.Handler) http.Handler

func NewRouter

func NewRouter(s rest.Server, store Store, email MailService, clock clock.Clock) *chi.Mux

Types

type MailService

type MailService interface {
	SendResetPassword(email string, token string) error
	SendPasswordResetSuccessful(email string) error
}

type PasswordResetToken

type PasswordResetToken struct {
	Token     string    `json:"token"`
	UserId    string    `json:"userId"`
	CreatedAt time.Time `json:"createdAt"`
	ExpiredAt time.Time `json:"expiredAt"`
	User      User      `json:"user"`
}

type School

type School struct {
	SchoolName string `json:"schoolName"`
}

type Session

type Session struct {
	Token  string `json:"token"`
	UserId string `json:"userId"`
	User   User   `json:"user"`
}

func GetSessionFromCtx

func GetSessionFromCtx(ctx context.Context) (*Session, bool)

type Store

type Store interface {
	ResolveInviteCode(inviteCodeId string) (*School, error)
	GetUserByEmail(email string) (*User, error)
	NewSession(userId string) (*Session, error)
	NewUser(email string, password string, name string, inviteCode string) (*User, error)
	GetSession(token string) (*Session, error)
	DeleteSession(token string) error
	NewPasswordResetToken(userId string) (*PasswordResetToken, error)
	GetPasswordResetToken(token string) (*PasswordResetToken, error)
	DoPasswordReset(userId string, newPassword string, token string) error
}

type User

type User struct {
	Id       string `json:"id"`
	Email    string `json:"email"`
	Name     string `json:"name"`
	Password []byte `json:"password"`
}

Jump to

Keyboard shortcuts

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