Base solution for your next web application
Open Closed

Auto login the admin user after creating a new tenant #12442


User avatar
0
csona created

Hi,

ASP.Net Zero Version: v10.2 ASP.Net Core + Angular

If we create a new tenant from the host login page, currently the system prompts to be redirected to the login screen for the admin user.

Is there a way to login the admin user automatically i.e. without having to be redirected to the login screen?

Thanks, Chaitanya

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

1 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @csona,

    After a new tenant is registered from the Host side, by default the system redirects you to the login page.
    If you want the admin user to be logged in automatically, you can achieve this by following these steps:

    1. Enable the setting:

      • Set "New registered tenants are active by default" to true.
    2. Disable email confirmation:

      • In Host Settings, set "Email confirmation required for login" to false.
    3. Auto-login after tenant registration:

      • After creating the new tenant, set the current TenantId and login the admin user manually: To do this, you need to go to register-tenant.component and update the else content in the subscribe method in the save method as given in the example below. When the user selects Subscription with the Paid type, it will direct them to the payment screen. You can perform the transaction in this else section after the payment process.
        .subscribe((result: RegisterTenantOutput) => {
            this._tenantRegistrationHelper.registrationResult = result;
    
            if (parseInt(this.model.subscriptionStartType.toString()) === SubscriptionStartType.Paid) {
                this._router.navigate(['account/gateway-selection'], {
                    queryParams: {
                        paymentId: result.paymentId,
                    },
                });
            } else {
                this._loginService.authenticateModel = new AuthenticateModel();
    
                this._loginService.authenticateModel.userNameOrEmailAddress = this.model.adminEmailAddress;
                this._loginService.authenticateModel.password = this.model.adminPassword;
                this._loginService.authenticateModel.rememberClient = true;
                this._loginService.authenticateModel.twoFactorRememberClientToken = null;
                this._loginService.authenticateModel.twoFactorVerificationCode = null;
                this._loginService.authenticateModel.singleSignIn = true;
                this._loginService.authenticateModel.captchaResponse = null;
                this._loginService.authenticateModel.returnUrl = '/app/admin/hostDashboard';
                abp.multiTenancy.setTenantIdCookie(result.tenantId);
    
                this._loginService.authenticate();
            }
        });
    
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)