// load roles func (this *UserService) LoadRoles(u *user.User) error { if len(u.Roles) > 0 { return nil } _, err := orm.NewOrm().LoadRelated(u, "Roles") if err == nil { for _, r := range u.Roles { if r.IsSystemRole { u.IsSystemAccount = true } } cachemanager.Put(fmt.Sprintf(USER_ID_CACHE_PATTERN, u.Id, u.Deleted), *u) } return err }
func (this UserService) InsertWithScope(tr orm.Ormer, u *user.User) error { u.PasswordSalt = GetUserSalt() if !utils.IsEmail(u.Email) { return errors.New("invalid email") } beego.Info(setting.SystemAdminEmails) if strings.Index(setting.SystemAdminEmails, u.Email) >= 0 { u.IsSystemAccount = true beego.Info(setting.SystemAdminEmails) } if _, err := tr.Insert(u); err != nil { return err } return nil }