middlewares

package
v0.0.0-...-e394574 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BackendLoginCheckFilter = func(ctx *context.Context) {
	if ctx.Request.URL.Path == "/backend/login" {
		return
	}
	tokenHeader := ctx.Request.Header["Token"]
	if len(tokenHeader) <= 0 {
		ctx.Abort(403, "NO AUTH")
	}
	sign := utils.SHA256Encode(os.Getenv("BACKEND_USER") + os.Getenv("BACKEND_PASS"))
	if sign != tokenHeader[0] {
		ctx.Abort(403, "NO AUTH")
	}
}
View Source
var LoginCheckFilter = func(ctx *context.Context) {
	userId := ctx.GetCookie("login_user_id")
	userSign := ctx.GetCookie("login_user_sign")
	user := models.Users{}
	if err := orm.NewOrm().QueryTable("users").Filter("id", userId).One(&user); err != nil {
		ctx.Redirect(302, beego.URLFor("UserController.Login"))
		return
	}
	if utils.AuthSignCheck(user.Id, user.Email, user.Password, userSign) == false {
		ctx.Redirect(302, beego.URLFor("UserController.Login"))
		return
	}
}

Functions

func BackendLoginCheck

func BackendLoginCheck()

func CorsHandler

func CorsHandler()

func LoginCheck

func LoginCheck()

Types

This section is empty.

Jump to

Keyboard shortcuts

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