Exemplo n.º 1
0
/* 根据话题id判断是否为其管理员 */
func (this *GameController) isManagerById(contro *beego.Controller) (bool, *models.Topic, *models.Game, *models.Member) {
	//实例化话题
	topic := &models.Topic{}
	ok := topic.FindById(contro.GetString("id"))
	if !ok { //不存在此话题
		return false, nil, nil, nil
	}
	//获取游戏信息
	game := &models.Game{}
	ok = game.FindPath(topic.Game)
	if ok { //存在此游戏
		//获取用户信息
		member := &models.Member{}
		if session := contro.GetSession("WOKUID"); session != nil {
			if ok := member.FindOne(session.(string)); ok {
				//如果是游戏管理员
				if member.Id == game.Manager {
					return true, topic, game, member
				} else {
					return false, topic, game, member
				}
			}
		}
	}
	return false, nil, nil, nil
}
Exemplo n.º 2
0
//判断是否登陆
func CheckAdminLogin(c *beego.Controller, t int64) {
	id, _ := c.GetSession("adminid").(int)
	username, _ := c.GetSession("adminname").(string)
	adminrole, _ := c.GetSession("adminrole").(int)
	if id == 0 || username == "" || adminrole == 0 {
		switch t {
		case 0:
			c.Redirect("/admin/login", 301)
		case 1:
			//返回JSON
			json := &models.TipJSON{}
			json.Status = models.TipError
			json.Message = "请先登录,再执行此操作"
			json.ReturnUrl = "/admin/login"

			c.Data["json"] = json
			c.ServeJson()
			c.StopRun()
		}

	}
	c.Data["AdminName"] = username
	c.Data["AdminId"] = id
	c.Layout = "admin/layout.tpl"
}
Exemplo n.º 3
0
/* 判断用户是否是游戏管理员 */
func (this *GameController) isManager(contro *beego.Controller) (bool, *models.Game, *models.Member) {
	//获取游戏信息
	game := &models.Game{}
	ok := game.FindPath(contro.GetString("category"))
	if !ok {
		return false, nil, nil
	}
	//获取用户信息
	member := &models.Member{}
	if session := contro.GetSession("WOKUID"); session != nil {
		if ok := member.FindOne(session.(string)); ok {
			//如果不是这个游戏的管理员则无权限
			if member.Id != game.Manager {
				return false, nil, nil
			} else {
				return true, game, member
			}
		} else {
			return false, nil, nil
		}
	} else {
		return false, nil, nil
	}
}