/// <summary>
        /// Extracts Organisation Db from request
        /// </summary>
        /// <param name="context"></param>
        /// <param name="dbIdentifier">Identifier of a db to extract</param>
        /// <returns></returns>
        public static OrganizationDatabase GetOrganisationDatabase(HttpContext context, string dbIdentifier = "")
        {
            //Note: as described in the OnActionExecuting, org related stuff is now always retrieved by the UserConfiguration attribute.
            //so provided an action is not an anonymous action, all the needed stuff should really be here!

            var orgId = GetOrganizationId(context);

            //Note: dependancy on the UserConfigurationActionFilterAtribute may not be that sensible. but i think should not hurt really...

            //grab the specified org db
            //Note: because user config is returned with org databases there is no need to load or dbs explicitly
            var orgDb = UserConfigurationActionFilterAtribute.GetUserConfiguration(context)?.GetOrganizationdatabase(orgId, dbIdentifier);

            if (orgDb == null)
            {
                throw new ArgumentException($"No database found for given organizationId: '{orgId}' and dbIdentifier: '{dbIdentifier}'.");
            }

            return(orgDb);
        }
        public async Task <IActionResult> GetUserOrgsAsync()
        {
            var uuid = Cartomatic.Utils.Identity.GetUserGuid();

            //this should not happen really as otherwise the user would not be authenticated
            if (!uuid.HasValue)
            {
                return(BadRequest());
            }

            try
            {
                IEnumerable <Organization> orgs = null;

                var userCfg = UserConfigurationActionFilterAtribute.GetUserConfiguration(HttpContext);
                if (userCfg.IsUser)
                {
                    orgs = await MapHiveUser.GetUserOrganizationsAsync(_dbCtx, uuid.Value);
                }

                //make it possible to return orgs for a token too
                if (userCfg.IsToken)
                {
                    orgs = new[] { await userCfg.Token.GetOrganizationAsync(_dbCtx) }
                }
                ;


                if (!orgs.Any())
                {
                    return(NotFound());
                }

                return(Ok(orgs));
            }
            catch (Exception ex)
            {
                return(HandleException(ex));
            }
        }