Base solution for your next web application

Activities of "amayorquin"

Hi, thank you for you response.

I just added a new dummy method in the api AccountController:

[Route("api/Account/Register")]
        [HttpPost]
        public AjaxResponse Register()
        {
            return new AjaxResponse(true);
        }

and just added the route in the Authenticate action:

[Route("api/Account/Authenticate")]

The Authenticate action is working, but the when I hit to Register action is calling the Authenticate action, even if I just call the api like this: <a class="postlink" href="http://localhost:6634/api/Account">http://localhost:6634/api/Account</a> is responding the Authenticate method

Those are the only changes I made. I don't know if I have to configurate something else.

Thanks in advance

Thank you very much for your responses. Finally I changed the way I call the stored procedure and works now.

I changed to this:

var  layers = Context.Database.SqlQuery<Layer>("GetPersonLayersBySecurityGroups @PersonId",
                new SqlParameter("@PersonId", personId)).ToList();
Answer

Thank you very much. This is how I was thinking to solve it, but I had the doubt if you did this on purpose. Thanks again

Answer

Thanks for your reply,

Actually I'm not change anything yet in code, I just downloaded the ABP and started to check and debug the code.

When I try Login with an external account previously registered (Google), this method is called (tenancyName is empty):

[UnitOfWork]
        public virtual async Task<ActionResult> ExternalLoginCallback(string returnUrl, string tenancyName = "")
        {
            var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
            if (loginInfo == null)
            {
                return RedirectToAction("Login");
            }

            //Try to find tenancy name
            if (tenancyName.IsNullOrEmpty())
            {
                var tenants = await FindPossibleTenantsOfUserAsync(loginInfo.Login);
                switch (tenants.Count)
                {
                    case 0:
                        return await RegisterView(loginInfo);
                    case 1:
                        tenancyName = tenants[0].TenancyName;
                        break;
                    default:
                        return View("TenantSelection", new TenantSelectionViewModel
                        {
                            Action = Url.Action("ExternalLoginCallback", "Account", new { returnUrl }),
                            Tenants = tenants.MapTo<List<TenantSelectionViewModel.TenantInfo>>()
                        });
                }
            }

            var loginResult = await _logInManager.LoginAsync(loginInfo.Login, tenancyName);

            switch (loginResult.Result)
            {
                case AbpLoginResultType.Success:
                    await SignInAsync(loginResult.User, loginResult.Identity, false);

                    if (string.IsNullOrWhiteSpace(returnUrl))
                    {
                        returnUrl = Url.Action("Index", "Home");
                    }

                    return Redirect(returnUrl);
                case AbpLoginResultType.UnknownExternalLogin:
                    return await RegisterView(loginInfo, tenancyName);
                default:
                    throw CreateExceptionForFailedLoginAttempt(loginResult.Result, loginInfo.Email ?? loginInfo.DefaultUserName, tenancyName);
            }
        }

The method that is called to find the possible tenants is the following:

[UnitOfWork]
        protected virtual async Task<List<Tenant>> FindPossibleTenantsOfUserAsync(UserLoginInfo login)
        {
            List<User> allUsers;
            using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))
            {
                allUsers = await _userManager.FindAllAsync(login);
            }

            return allUsers
                .Where(u => u.TenantId != null)
                .Select(u => AsyncHelper.RunSync(() => _tenantManager.FindByIdAsync(u.TenantId.Value)))
                .ToList();
        }

but like I said before, looks like is searching only in the host database

Hi, I have the same error in the last version, I'm using different database per tenant. Did you fix it?

Showing 1 to 5 of 5 entries