routers

package
v0.0.0-...-5ee4d6d Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckAdminLogin = func(ctx *context.Context) {
	token := ctx.Input.Cookie("token")
	if token == "" {
		if ctx.Request.RequestURI == "/admin/signin.html" {
			return
		}
		ctx.Redirect(301, "/admin/signin.html")
		return
	}

	admin, err := auth.CheckToken(token)
	if err != nil || admin.Type != models.USER_TYPE_ADMIN {
		ctx.Redirect(301, "/admin/signin.html")
		return
	}

	ctx.Input.SetData("isLogin", admin)
	if ctx.Request.RequestURI == "/admin/signin.html" {
		ctx.Redirect(301, "/admin/dashboard.html")
		return
	}
}

CheckAdminLogin 检查后台管理员是否登录

View Source
var CheckOpneAPIAuth = func(ctx *context.Context) {
	var token string
	ctx.Input.Bind(&token, "token")
	if token == "" {
		ctx.Output.JSON(admin.BizException("缺失token", 600), false, false)
		return
	}
	manager, err := auth.CheckToken(token)
	if err != nil || manager.Type != models.USER_TYPE_MANAGER {
		ctx.Output.JSON(admin.BizException("无效token", 600), false, false)
		return
	}
}

CheckOpneAPIAuth 检查后台openapi权限

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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