auth

package
v0.0.0-...-41417f0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultKey = "yitum.com/mall/auth"
	SessionKey = "AUTHUNIQUEID"
	// RedirectUrl should be the relative URL for your login route
	RedirectUrl string = "/user/login"

	// RedirectParam is the query string parameter that will be set
	// with the page the user was trying to visit before they were
	// intercepted.
	RedirectParam string = "return_url"
)

Functions

func AuthenticateSession

func AuthenticateSession(s sessions.Session, a *Auth) error

AuthenticateSession will mark the session and user object as authenticated. Then the Login() user function will be called. This function should be called after you have validated a user.

func LoginRequired

func LoginRequired() gin.HandlerFunc

func Logout

func Logout(s sessions.Session, a *Auth)

Logout will clear out the session and call the Logout() user function.

func New

func New() gin.HandlerFunc

func UpdateUser

func UpdateUser(s sessions.Session, a *Auth) error

UpdateUser updates the User object stored in the session. This is useful incase a change is made to the user model that needs to persist across requests.

Types

type Auth

type Auth struct {
	Uid       uint32 `json:"uid,omitempty"`
	Nickname  string `form:"nickname" json:"nickname,omitempty"`
	Avatar    string `form:"avatar" json:"avatar,omitempty"`
	Password  string `form:"password" json:"-"`
	Gender    int64  `json:"gender,omitempty"`
	Birthday  int64  `json:"birthday,omitempty"`
	CreatedAt int64  `gorm:"column:created_time" json:"created_time,omitempty"`
	UpdatedAt int64  `gorm:"column:updated_time" json:"updated_time,omitempty"`
	// contains filtered or unexported fields
}

func Default

func Default(c *gin.Context) *Auth

shortcut to get Auth

func (*Auth) IsAuthenticated

func (u *Auth) IsAuthenticated() bool

func (Auth) TableName

func (Auth) TableName() string

func (*Auth) UniqueId

func (u *Auth) UniqueId() uint32

Jump to

Keyboard shortcuts

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