Base solution for your next web application

Activities of "deventerprise"

I have a similar requirement to this: https://support.aspnetzero.com/QA/Questions/977

I do not want the users to select the tenant and neither do I want to provide multiple URL's/domains. Users will register and login with a unique email address (disabling username completely) and select the tenant they are registering for from a drop-down. From the login details you could determine the tenant since it's in the database table, problem is you need the tenant up-front to actually login.

Is there any way to autmatically set the tenant based on a successfull login WITHOUT providing a tenant and using the tenant associated with the user account? When a user registers they will select the tenant from a list on the registration page so there is no need to be on a domain or select it separately for a session.

Disabling the filters works but the the login fails with an error like "USERNAME already exists". I updated all usernames in the database to match the email address and modified registration to save the email address as username with validation etc.

When logging in with an updated user, a duplicate user is added to the database somehow with the username "admin" again, and the issue above happens all over again. [email protected] is also added to the database again even though the original user details were modified now having two admins for each tenant.

Everything else seems to work well, appending null to the tenant cookie fails so tehre is a bug there and you should rather call .Delete.

How do you prevent these new admin users from being generated?

Figured out why the admin users get created, this is because if a user with "admin" does not exist then one is created for you. This happens in TenantRoleAndUserBuilder.cs inside CreateRolesAndUsers. during startup.

More users are created automatically in HostRoleAndUserCreator.cs inside CreateHostRoleAndUsers, also removed this to avoid it.

I just finished it up now. Was a little tricky to get it right but your advice did help put on the right track as to what I needed to do. Tested everything works in terms of logging in even with the wrong cookie and impersonation.

Was confused about the logins being created but made some other tweaks there to identify tenant admins a bit better so that I could use phone number user names (off-topic). For anyone else reading, those users are also required for unit tests so don't just remove that code.

Experiencing two obvious issues when publishing the application live, these do not occur during development.

  1. A CSS file fails to load (metronic-customize.min.css). It seems like a minified version of the origial file is not created. There are two that are trying to get loaded, /Common/Styles/Themes/default/metronic-customize.min.css and /Common/Styles/metronic-customize.min.css
  2. The default dashboard does not load correctly with te JS error in host-dashboard-libs.min.js "Uncaught Error: Invalid dimensions for plot, width = 745.313, height = 0"

These occured in version 6.4 and still after updating to 6.5. Are these known issues?

OK, I cannot seem to register users if they pass in the tenant ID.

CurrentUnitOfWork.SetTenantId(model.TenantId);

var user = await _userRegistrationManager.RegisterAsync(
    model.Name,
    model.Surname,
    model.EmailAddress,
    model.PhoneNumber,
    model.Password,
    false,
    _appUrlService.CreateEmailActivationUrlFormat(model.TenantId)
);

user.PhoneNumber = model.PhoneNumber;
user.ShouldChangePasswordOnNextLogin = false;

await CurrentUnitOfWork.SaveChangesAsync();

I rexpected the above to work, but instead I get an exception saying "InvalidOperationException: Can not register host users!".

CheckForTenant() in UserRegistrationManager only checks the session, not the unit of work and since this value cannot be set, how do I set in in an unauthorized Register call?

Figured out you need to set the Abp.TenantId header: https://support.aspnetzero.com/QA/Questions/6269

This is the same problem as seen here: https://support.aspnetzero.com/QA/Questions/6194#answer-f37480ee-3374-e2de-e53f-39eb1a9bcef4

Minified versions of these files don't exist and are not created as part of a production build. Some of the theme files are not empty so you should not remove them.

This is a problem with the bundle config that does not minify the customization files: https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/bundleconfig.json

You need to bundle the base on as well as all the all the themes:

  {
    "outputFileName": "wwwroot/Common/Styles/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/default/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/default/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/blue/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/blue/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/green/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/green/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/pink/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/pink/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/yellow/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/yellow/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme2/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme2/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme3/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme3/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme7/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme7/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme8/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme8/metronic-customize.css"
    ]
  },
  {
    "outputFileName": "wwwroot/Common/Styles/Themes/theme11/metronic-customize.min.css",
    "inputFiles": [
      "wwwroot/Common/Styles/Themes/theme11/metronic-customize.css"
    ]
  }

And also remove the main customzation from the common-styles.css bundle at the top:

  {
    "outputFileName": "wwwroot/view-resources/Areas/App/Views/_Bundles/common-styles.css",
    "inputFiles": [
      "wwwroot/Common/Styles/**/*.css",
      "wwwroot/fonts/fonts-poppins.css",
      "wwwroot/fonts/fonts-roboto.css",
      "!wwwroot/Common/Styles/**/*.min.css",
      "!wwwroot/Common/Styles/Themes/**/*.css",
      "!wwwroot/Common/Styles/abp-zero-template-rtl.css",
+    "!wwwroot/Common/Styles/metronic-customize.css*.css",
      "!wwwroot/Common/Styles/metronic-customize-top-menu*.css"
    ]
  },

That just leaves the JS error "Invalid dimensions for plot" on the dashboard to try and resolve.

@exInt: to fix the missing customzations issue in the release build you'll need to add the files to the bundle config, seems like someone missed this configuration: https://support.aspnetzero.com/QA/Questions/6282#answer-79e97d62-653d-e621-96cc-39eb621f2e19

Showing 1 to 10 of 32 entries