Starts in:
2 DAYS
11 HRS
7 MIN
24 SEC
Starts in:
2 D
11 H
7 M
24 S

Activities of "Repunjay_TASC"

Hi maliming,

Thanks very much for your support. We were able to resolve the issue and are now successfully redirected to the dashboard.

hi

https://us05web.zoom.us/j/83893176702?pwd=U6frjNspBIgK1f388xsfk7wAMY9406.1

Sorry, My laptop got restarted; i can i connect now ?

Hi,

// AS per your refernec i have added this method await _identityOptions.SetAsync();

I am calling the method twice. The first time I receive a response with success: false. However, based on the email ID, I check if the user exists or not. After that, when I call the method again, I get a success response. Note :- Second time call just for checking pursue var result = await _signInManager.ExternalLoginSignInAsync( info.LoginProvider, info.ProviderKey, isPersistent: false, bypassTwoFactor: true );

As per your suggestion, I have already followed the steps below:

If the user does not exist in the system, I have added the user to the database and assigned the role as well. Still not work can you pls review this code once

[HttpGet] public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null) { if (remoteError != null) { return RedirectToAction("Login"); }

try
{
    await _identityOptions.SetAsync();    // AS per your refernec i have added this method 

    // Get the external login information
    var info = await _signInManager.GetExternalLoginInfoAsync();
    if (info == null)
    {
        // If external login info is not available, redirect to login
        return RedirectToAction("Login");
    }

    // Try to sign in the user using the external login info
    var result = await _signInManager.ExternalLoginSignInAsync(
        info.LoginProvider,
        info.ProviderKey,
        isPersistent: false,
        bypassTwoFactor: true
    );


    // Otherwise, proceed to register a new user
    var email = info.Principal.FindFirstValue(ClaimTypes.Email);
    var tokens = await ExchangeCodeForTokensAsync();
    var response = await GetUserDeatilsInfo(tokens.AccessToken, info.ProviderKey);
    var rolesName = await GetUserRolesdataAsync(tokens.AccessToken, response.UserId);


    var input = new IdentityUserCreateDto
    {
        UserName = response.Email,
        Email = response.Email,
        Password = "1!1234", // You may want to change this to a more secure password generation strategy
        Name = response.Nickname,
        Surname = response.Nickname,
        PhoneNumber = "9766640367", // Use a valid phone number
        IsActive = true,
        ShouldChangePasswordOnNextLogin = false,
        LockoutEnabled = true,
        RoleNames = [rolesName] // Assuming rolesName is a single role; adjust if it's a list of roles
    };

    // Get the tenant configuration
    var configTenantId = _configuration.GetSection("TenantId").Value;

    // Change the tenant context (assuming multi-tenant setup)
    using (_currentTenant.Change(Guid.Parse(configTenantId)))
    {
        // Create the user and assign roles
        var createUserResult = await CreateAsync(input, info);
        if (createUserResult)
        {
            var user = await _identityUserManager.FindByEmailAsync(response.Email);
            if (user != null)
            {
                // Mark the user as external
                user.IsExternal = true;
                await _userRepository.UpdateAsync(user);

                // Update the security stamp for the user
                await _identityUserManager.UpdateSecurityStampAsync(user);

                // Add the external login
                await _identityUserManager.AddLoginAsync(user, info);


                // Try to sign in the user using the external login info
                var result1 = await _signInManager.ExternalLoginSignInAsync(
                    info.LoginProvider,
                    info.ProviderKey,
                    isPersistent: false,
                    bypassTwoFactor: true
                );

                // Sign in the user
                await _signInManager.SignInAsync(user, false);

                // Redirect to the originally requested page or the default home page
                return Redirect(returnUrl);
            }
        }
        else
        {
            // In case user creation fails, redirect to the login page
            return RedirectToAction("Login");
        }
    }
}
catch (Exception ex)
{
    return RedirectToAction("Error"); // Redirect to an error page or show a friendly error message
}

// Default redirect if something unexpected happens
return Redirect(returnUrl);

}

public async Task<bool> CreateAsync(IdentityUserCreateDto input, ExternalLoginInfo info) { _logger.LogInformation($"CustomAddUserAndRoles: in CreateAsync(): START, Date Time: {DateTime.UtcNow}");

   try
   {
     
       // Check if user exists by email ID
       var existingUser = await _identityUserManager.FindByEmailAsync(input.Email);
       if (existingUser != null)
       {
           await _identityUserManager.RemoveFromRolesAsync(existingUser, input.RoleNames);
           await assignRoles(input, existingUser);
           _logger.LogError($"CustomAddUserAndRoles: in CreateAsync(): Message: User already exists; role updated successfully, Date Time: {DateTime.UtcNow}");
       }
       else
       {
           Guid userId;
           var newUserName = await GetUniqueUserNameAsync(input.Name.Trim(), input.Surname.Trim());
           var user = new IdentityUser(_guidGenerator.Create(), newUserName.Trim(), input.Email, _currentTenant.GetId());

           var creationResult = await _identityUserManager.CreateAsync(user, input.Password.Trim());
           creationResult.CheckErrors();

           await _identityUserManager.SetEmailAsync(user, input.Email.Trim());

           user.Name = input.Name.Trim();
           user.Surname = input.Surname.Trim();

           userId = user.Id;

           var tenant = _currentTenant.GetId();
           var email = info.Principal.FindFirstValue(ClaimTypes.Email);
           // Adding claims
           var claimsToAdd = new List&lt;Claim&gt;
               {
                   new Claim(ClaimTypes.Email, email.Trim()),
               };

           await _identityUserManager.AddClaimsAsync(user, claimsToAdd);
           await assignRoles(input, user);

           await _unitOfWorkManager.Current.SaveChangesAsync();

           var userDetails = await _identityUserManager.GetByIdAsync(userId);
           if (userDetails != null)
           {
               userDetails.SetProperty("Status", 1);
               userDetails.SetProperty("Language", "en");
           }

           await _unitOfWorkManager.Current.SaveChangesAsync();
           _logger.LogInformation($"CustomAddUserAndRoles: in CreateAsync() END: Message: create user and roles assigned successfully, Date Time: {DateTime.UtcNow}");
          
       }
       return true;
   }
   catch (Exception ex)
   {
       _logger.LogError($"CustomAddUserAndRoles: Error in CreateAsync(): Message: {ex.Message}| Source: {ex.Source} | Inner Exception: {ex.InnerException} |Stack Trace: {ex.StackTrace}, Date Time: {DateTime.UtcNow}");
       return false;
   }

}

hi

What are the values in info ?

var info = await _signInManager.GetExternalLoginInfoAsync(); get external login info like like info.ProviderKey(External userID) .

If the external user is not in your system. eg you first use google account(123@google.com) to login. but the 123@google.com doesn't exist in your system. We will register a new user for it.

ok got it, let me check again and get back to you.

In the end we will call await SignInManager.SignInAsync(user, false); to issuer the cookies. https://github.com/abpframework/abp/blob/dev/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs#L243-L282

Hi ,

below method not present in my code, however i have added but i received is success false pls find attached screen shot. This is correct approach to call this method pls check and let me know.

await SignInManager.ExternalLoginSignInAsync

Hi,

The redirect URI issue is resolved, but it's showing the login page. Should be log automatically.

I have shared hra log over email pls check and mean while me also looking into it.

Thanks in advance.

ok sure

this is correct way ? Still getting same issue

hi I have checked your angular app.

The angular should init the code flow and redirect to autherver website.

This is the default behavior of abp angular app.

angular app -> click login button -> redirect to authserver website(login page.).

Can you check your app to make this?

We are very close to resolve this issue thanks for your support.

As per the reference link you shared, I have made changes to the environment.ts file in Angular.

Earlier, this API was not called from Angular, but now it seems we've taken a step forward, and the connect/authorize method is automatically called.

Error :- error:invalid_request error_description:The specified 'redirect_uri' is not valid for this client application.

Below POC screen shot

I have cross-checked the POC and our existing project up to the connect/authorize implementation, and everything is the same. I will also share the HRA. We are very close to successfully completing the connect/authorize process, after that initiate code flow and get angular access like below POC screen shot.

please advise and thanks in advance. mean while me also looking into it

hi

This issue is highly escalated into our organization and we certainly need you to look into this matter and provide support to resolve it.

Can you ask other colleagues if they can reproduce the problem?

I have explained a lot of the content of the problem.

References: https://abp.io/support/questions/8267/Tenant-Id-and-Tenant-Name-Not-Set-in-Header-After-Dashboard-Redirect-SSO-OIDC?CurrentPage=2#answer-3a163ae6-c2bb-7256-cbd1-03ecdb09add8 https://abp.io/support/questions/8267/Tenant-Id-and-Tenant-Name-Not-Set-in-Header-After-Dashboard-Redirect-SSO-OIDC?CurrentPage=2#answer-3a163adf-89f4-6c29-5e28-87e18a775dd7

Hi ,

I have also observed this issue in my project, but we are unsure how to fix it and are requesting your assistance with an exact solution. Additionally, i have mention there could you confirm whether my observations are correct? Please suggest any improvements.

References: https://abp.io/qa/questions/8267/3a1631ff-02f3-d3aa-8ce8-71ef2e8c7a4b https://abp.io/qa/questions/8267/3a163685-5208-701a-241c-c522991ace5a

However, we both understand what the issue is, but I am unable to resolve it, which is why we need your assistance.

Showing 11 to 20 of 191 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06