Exemplo n.º 1
0
func CheckAdmin(name, pass string) (*models.Person, error) {
	bm := beego.AppConfig.String("bm")
	admin := beego.AppConfig.String("admin")
	adminPass := beego.AppConfig.String("pass")
	if name == admin && models.MD5(pass, bm) == adminPass {
		person := models.NewPerson("管理员", "admin", "***", "", "")
		person.Id = -1
		return person, nil
	}
	return nil, errors.New("不是管理员")
}
Exemplo n.º 2
0
func (this *LoginController) Md5() {
	val := this.GetString("val")
	this.Ctx.Output.Body([]byte(models.MD5(val, beego.AppConfig.String("bm"))))
}