Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "michelmk2"

<cite>ismcagdas: </cite> It should be something like this;

public class MyDomainTenantResolveContributor : ITenantResolveContributor, ITransientDependency 
{
  public int? ResolveTenantId()
  {
  	if (_multiTenancyConfiguration.DomainFormat.IsNullOrEmpty())
  	{
  		return null;
  	}

  	var httpContext = _httpContextAccessor.HttpContext;
  	if (httpContext == null)
  	{
  		return null;
  	}
  	 
  	var hostName = httpContext.Request.Host.Host.RemovePreFix("http://", "https://").RemovePostFix("/");
  	var domainFormat = _multiTenancyConfiguration.DomainFormat.RemovePreFix("http://", "https://").Split(':')[0].RemovePostFix("/");
  	var result = new FormattedStringValueExtracter().Extract(hostName, domainFormat, true, '/');

  	if (!result.IsMatch || !result.Matches.Any())
  	{
  		return null;
  	}

  	var tenancyName = result.Matches[0].Value;
  	if (tenancyName.IsNullOrEmpty())
  	{
  		return null;
  	}

  	if(tenancyName == "admin"){ // this is the added line
  		return null;
  	}
  	
  	if (string.Equals(tenancyName, "www", StringComparison.OrdinalIgnoreCase))
  	{
  		return null;
  	}

  	var tenantInfo = _tenantStore.Find(tenancyName);
  	if (tenantInfo == null)
  	{
  		return null;
  	}

  	return tenantInfo.Id;	
  }
}

Then, add it to resolvers in the PreInitalize method of your web module

Configuration.MultiTenancy.Resolvers.Insert(0,new MyDomainTenantResolveContributor());

Still doesn't work unfortunately. Getting the following error:

System.ArgumentNullException: Value cannot be null.
Parameter name: value
   at System.Security.Claims.Claim..ctor(String type, String value, String valueType, String issuer, String originalIssuer, ClaimsIdentity subject, String propertyKey, String propertyValue)
   at System.Security.Claims.Claim..ctor(String type, String value)
   at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory`1.&lt;GenerateClaimsAsync&gt;d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory`2.<GenerateClaimsAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Identity.UserClaimsPrincipalFactory`1.&lt;CreateAsync&gt;d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Authorization.AbpUserClaimsPrincipalFactory`2.<CreateAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwa...

<cite>ismcagdas: </cite> Hi @michelmk2,

You need to implement your own DomainTenantResolveContributor and return null if found tenancy name is admin. See <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.AspNetCore/AspNetCore/MultiTenancy/DomainTenantResolveContributor.cs">https://github.com/aspnetboilerplate/as ... ributor.cs</a>

Thanks for your reply! Do you have an example on how to implement this? Because i'm not sure how and where to put it!

Thank you so much!

<cite>aaron: </cite> Fixed in v5.6

Hmmm, still doesn't work... getting the following error when switching back to host:

System.Exception: Current tenant is different than given tenant. AbpSession.TenantId: 18, given tenantId: 
   at Robin.Authorization.Impersonation.ImpersonationManager.CheckCurrentTenant(Nullable`1 tenantId)
   at Robin.Authorization.Impersonation.ImpersonationManager.&lt;GetImpersonatedUserAndIdentity&gt;d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Robin.Web.Controllers.AccountController.&lt;ImpersonateSignIn&gt;d__51.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Threading.InternalAsyncHelper.&lt;AwaitTaskWithPostActionAndFinallyAndGetResult&gt;d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at lambda_method(Closure , Object )
   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfActionResultExecutor.<Execute>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runti...

<cite>ismcagdas: </cite> @michelmk2 then there might be a bug. What is your current ABP version ? If it is not the latest one, can you try with latest ABP (v3.6) ?

Hey,

I just upgrade to ABP version 3.6 and it still doesn't work :cry: , same error. Got any more suggestions?

Thanks!

<cite>ismcagdas: </cite> @michelmk2 could it be a cache issue ? How did you grant the permission to user ?

I granted the permission via the Administration -> Users -> Permissions window. Do you have any suggestions I could try?

Thanks!

<cite>aaron: </cite> Show screenshot of PermissionSettings table.

There you go, [https://i.imgur.com/iBsXMwt.png])

Thanks!

<cite>ismcagdas: </cite> I have created an issue here <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/issues/605">https://github.com/aspnetzero/aspnet-zero/issues/605</a>. We will try to fix it soon.

Thanks!

Ahh got it fixed! So what happens is that the last .js is trimmed of the output file names, and then .min.js is added. So that leaves you with .min.min.js.

Changing var minifiedJsOutputFile = outputFileName.substr(0, outputFileName.lastIndexOf(".")) + ".min.js"; to var minifiedJsOutputFile = outputFileName.substr(0, outputFileName.lastIndexOf(".")) + ".js";

And the same for css files, fixed the problem!

Thanks guys!

<cite>alirizaadiyahsi: </cite> Hi @michelmk2, we resolved this issue.

Check related change: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/commit/3c552b4648377d8216256af0b01b37564b44e2dd#diff-16281b32d0eef5f5b47ce3b2c590de12">https://github.com/aspnetzero/aspnet-ze ... b2c590de12</a>

Hi, Thanks for the link! What I see now, is that gulp generates *.min.min.js and *.min.min.css files. The min min files are no longered generated if I re-add the || outputFileName.endsWith('.min.js') line at the bundle.createMinified step. But then i'm back to my initial problem of the files not being minified :(.

Greetings

You mean, like this right?

gulp.task("min:js", function () {
    var tasks = getBundles(regex.js).map(function (bundle) {
        var outputFileName = getOutputFileName(bundle.outputFileName);
        var outputFolder = getOutputFolder(bundle.outputFileName);

        return gulp.src(bundle.inputFiles)
            .pipe(concat(outputFileName))
            .pipe(gulp.dest(outputFolder));
    });

    if (gutil.env.prod) {
        var minifyTasks = getBundles(regex.js).map(function (bundle) {
            var outputFileName = getOutputFileName(bundle.outputFileName);
            var outputFolder = getOutputFolder(bundle.outputFileName);

            if (bundle.createMinified === false || outputFileName.endsWith('.min.js')) {
                return null;
            }

            var minifiedJsOutputFile = outputFileName.substr(0, outputFileName.lastIndexOf(".")) + ".min.js";
            return gulp.src(bundle.inputFiles)
                .pipe(concat(minifiedJsOutputFile))
                .pipe(uglify())
                .pipe(gulp.dest(outputFolder));
        });

        for (var i = 0; i < minifyTasks.length; i++) {
            if (minifyTasks[i] == null) {
                continue;
            }

            tasks.push(minifyTasks[i]);
        }
    }

    return merge(tasks);
}).on('error', function (error) {
    gutil.log(error.message);
});

Unfortunately this doesn't give me any errors :(.

Showing 11 to 20 of 23 entries