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

External authentication. There is no error for deleted or inactive customer #7600

Open
ahjszll opened this issue Feb 22, 2025 · 0 comments
Open

Comments

@ahjszll
Copy link

ahjszll commented Feb 22, 2025

V4.80.3
When a user is deleted, the delete attribute is set to true,
But there was no warning prompt when using third-party login,

I temporarily used the following code modification, perhaps you will have a better way to modify it in the future

src/Libraries/Nop.Services/Authentication/External/ExternalAuthenticationService.cs line:274

`
public virtual async Task AuthenticateAsync(ExternalAuthenticationParameters parameters, string returnUrl = null){
ArgumentNullException.ThrowIfNull(parameters);

    var customer = await _workContext.GetCurrentCustomerAsync();
    var store = await _storeContext.GetCurrentStoreAsync();
    if (!await _authenticationPluginManager.IsPluginActiveAsync(parameters.ProviderSystemName, customer, store.Id))
        return await ErrorAuthenticationAsync(new[] { "External authentication method cannot be loaded" }, returnUrl);

    //get current logged-in user
    var currentLoggedInUser = await _customerService.IsRegisteredAsync(customer) ? customer : null;

    //authenticate associated user if already exists
    var associatedUser = await GetUserByExternalAuthenticationParametersAsync(parameters);
    if (associatedUser != null)
    {
        /** my new code
        if (associatedUser.Deleted)
            return await ErrorAuthenticationAsync(new List<string> { "****" }, "");
        if (!associatedUser.Active)
            return await ErrorAuthenticationAsync(new List<string> { "****" }, "");
        //only registered can login
        if (!await _customerService.IsRegisteredAsync(associatedUser))
            return await ErrorAuthenticationAsync(new List<string> { "****" }, "");
        **/

        return await AuthenticateExistingUserAsync(associatedUser, currentLoggedInUser, returnUrl);
    }

    //or associate and authenticate new user
    return await AuthenticateNewUserAsync(currentLoggedInUser, parameters, returnUrl);
}

`

@AndreiMaz AndreiMaz changed the title After the user is deleted, there is no error warning when logging in with the extension External authentication. There is no error for deleted customer Feb 23, 2025
@AndreiMaz AndreiMaz changed the title External authentication. There is no error for deleted customer External authentication. There is no error for deleted or inactive customer Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants