You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: memphis_handlers_rbac.go
    path of file: ./repos/memphis/server
    
    the code of the file until where you have to start completion: package server

import (
	"fmt"
	"strings"

	"github.com/memphisdev/memphis/db"
	"github.com/memphisdev/memphis/models"
)

const (
	inboxSubject   = "_INBOX.>"
	wildCardSuffix = ".>"
)

// the function returns a bool for is allowd to create and a bool for if a reload is needed
func ValidateStationPermissions(rolesId []int, stationName, tenantName, operation string) (bool, bool, error) {
	// if the user dosent have a role len rolesId is 0 then he allowd to create
	// TODO: add check if denied when we allow to deny
	if len(rolesId) == 0 {
		neededReload, err := checkTenantPermissionsUsage(tenantName)
		if err != nil {
			return false, false, err
		}
		return
    
func GetUserAllowedStations(userRoles []int, tenantName string) ([]models.Station, []models.Station, error) {
	permissions, err := db.GetUserPermissions(userRoles, tenantName)
	if err != nil {
		return nil, nil, err
	}

	var permissionsAllowReadPattern []string
	var permissionsAllowWritePattern []string

	for _, permission := range permissions {
		if permission.RestrictionType == "allow" {
			if permission.Type == "read" {
				permissionsAllowReadPattern = append(permissionsAllowReadPattern, permission.Pattern)

			} else if permission.Type == "write" {
				permissionsAllowWritePattern = append(permissionsAllowWritePattern, permission.Pattern)
			}
		}
	}

	allowReadStations, err := db.GetStationsByPattern(permissionsAllowReadPattern, tenantName)
	if err != nil {
		return nil, nil, err
	}

	allowWriteStations, err := db.GetStationsByPattern(permissionsAllowWritePattern, tenantName)
	if err != nil {
		return nil, nil, err
	}

	return allowReadStations, allowWriteStations, nil
}