Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to override Volo.Abp.Account.Public.Web.Areas.Account.Controllers.AccountController #21803

Closed
1 task done
alexandis opened this issue Jan 3, 2025 · 7 comments
Closed
1 task done

Comments

@alexandis
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Description

I am trying to resolve the issue of letting the authenticated user in in tab #2 if he is already authenticated in tab #1 of the browser.
For this, I am trying to override ABP AccountController.

Reproduction Steps

Adding this to OpenID server project:

namespace Volo.Abp.Account.Public.Web.Areas.Account.Controllers
{
    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(AccountController))]
    public class AbxAccountAcontroller : AccountController
    {
        public AbxAccountAcontroller(SignInManager<Identity.IdentityUser> signInManager, IdentityUserManager userManager, IdentitySecurityLogManager identitySecurityLogManager, IIdentityLinkUserAppService identityLinkUserAppService, ICurrentPrincipalAccessor currentPrincipalAccessor, IOptions<IdentityOptions> identityOptions, IOptionsSnapshot<reCAPTCHAOptions> reCaptchaOptions, ISettingProvider settingProvider, IdentityDynamicClaimsPrincipalContributorCache identityDynamicClaimsPrincipalContributorCache)
            : base(signInManager, userManager, identitySecurityLogManager, identityLinkUserAppService, currentPrincipalAccessor, identityOptions, reCaptchaOptions, settingProvider, identityDynamicClaimsPrincipalContributorCache)
        {
        }

        [HttpPost]
        [Route("login")]
        public override async Task<AbpLoginResult> Login(Models.UserLoginInfo login)
        {
            base.ValidateLoginInfo(login);

            await base.ReplaceEmailToUsernameOfInputIfNeeds(login);

            if (HttpContext.User.Identity.IsAuthenticated)
            {
                // If already authenticated, return a successful login result
                return new AbpLoginResult(LoginResultType.Success);
            }

            return await base.Login(login);
        }
    }
}

Expected behavior

The class code is triggered

Actual behavior

The class code is not triggered

Regression?

No response

Known Workarounds

No response

Version

8.1.3

User Interface

Angular

Database Provider

EF Core (Default)

Tiered or separate authentication server

Separate Auth Server

Operation System

Windows (Default)

Other information

No response

@alexandis alexandis added the bug label Jan 3, 2025
@maliming maliming removed the bug label Jan 3, 2025
@maliming
Copy link
Member

maliming commented Jan 3, 2025

hi

We have a ReplaceControllers attribute.

#16617

@alexandis
Copy link
Author

I have made this:

[ReplaceControllers(typeof(AccountController))]
public class AbxAccountAcontroller : AccountController

and it is still not triggered. Do i need to do something additionally?

@maliming
Copy link
Member

maliming commented Jan 6, 2025

Please upload your test project to Github.

@maliming
Copy link
Member

maliming commented Jan 6, 2025

image

@alexandis
Copy link
Author

alexandis commented Jan 6, 2025

I did not check this such a way.
What I expect is this controller to be invoked when I am trying to login from Angular app (the part of the git repository, too) - but it is not.

@maliming
Copy link
Member

maliming commented Jan 7, 2025

Angular app use code flow to get access tokens, it will not call this controller.

https://github.com/alexandis/Test/blob/b9106b13835c3e29c225750b26eb4da1a6deeca1/angular/src/environments/environment.ts#L9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants