示例#1
0
文件: login.go 项目: tangseng/gtt
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("不是管理员")
}
示例#2
0
文件: person.go 项目: tangseng/gtt
func (this *PersonController) Add() {
	if !this.prefixCheck() {
		return
	}
	personOption := models.NewPersonOption()
	person, err := personOption.ReadByName(this.Name)
	if err == nil && person.Id > 0 {
		this.error("user")
		return
	}
	person, err = personOption.ReadByLoginName(this.LoginName)
	if err == nil && person.Id > 0 {
		this.error("login")
		return
	}
	id, err := personOption.Insert(models.NewPerson(this.Name, this.LoginName, this.LoginPass, this.Color, this.Group))
	if err != nil {
		this.error("err")
		return
	}
	this.success(map[string]interface{}{"id": id})
}