func (permission Permission) HasPermission(mode PermissionMode, roles ...interface{}) bool {
	var roleNames []string
	for _, role := range roles {
		if r, ok := role.(string); ok {
			roleNames = append(roleNames, r)
		} else if roler, ok := role.(Roler); ok {
			roleNames = append(roleNames, roler.GetRoles()...)
		} else {
			fmt.Printf("invalid role %#v\n", role)
			return false
		}
	}

	if len(permission.DeniedRoles) != 0 {
		if DeniedRoles := permission.DeniedRoles[mode]; DeniedRoles != nil {
			if includeRoles(DeniedRoles, roleNames) {
				return false
			}
		}
	}

	// return true if haven't define allowed roles
	if len(permission.AllowedRoles) == 0 {
		return true
	}

	if AllowedRoles := permission.AllowedRoles[mode]; AllowedRoles != nil {
		if includeRoles(AllowedRoles, roleNames) {
			return true
		}
	}

	return false
}
func (permission Permission) HasPermission(mode PermissionMode, roles ...interface{}) bool {
	var roleNames []string
	for _, role := range roles {
		if r, ok := role.(string); ok {
			roleNames = append(roleNames, r)
		} else if roler, ok := role.(Roler); ok {
			roleNames = append(roleNames, roler.GetRoles()...)
		} else {
			fmt.Printf("invalid role %#v\n", role)
			return false
		}
	}

	if len(permission.DeniedRoles) != 0 {
		if DeniedRoles := permission.DeniedRoles[mode]; DeniedRoles != nil {
			if includeRoles(DeniedRoles, roleNames) {
				return false
			}
		}
	}

	
	if len(permission.AllowedRoles) == 0 {
		return true
	}

	if AllowedRoles := permission.AllowedRoles[mode]; AllowedRoles != nil {
		if includeRoles(AllowedRoles, roleNames) {
			return true
		}
	}

	return false
}
func ( permission Permission ) HasPermission ( mode PermissionMode , roles ... interface { } ) bool { var roleNames [ ] string for _ , role := range roles { if r , ok := role . ( string ) ; ok { roleNames = append ( roleNames , r ) } else if roler , ok := role . ( Roler ) ; ok { roleNames = append ( roleNames , roler . GetRoles ( ) ... ) } else { fmt . Printf ( " \n " , role ) return false } } if len ( permission . DeniedRoles ) != 0 { if DeniedRoles := permission . DeniedRoles [ mode ] ; DeniedRoles != nil { if includeRoles ( DeniedRoles , roleNames ) { return false } } } // return true if haven't define allowed roles if len ( permission . AllowedRoles ) == 0 { return true } if AllowedRoles := permission . AllowedRoles [ mode ] ; AllowedRoles != nil { if includeRoles ( AllowedRoles , roleNames ) { return true } } return false }
// HasPermission check roles has permission for mode or not
HasPermission check roles has permission for mode or not