Activities of "safi"

Hi

I am using abp old version i.e 4.4.3 in my project. I am facing one issue here remember me functionality is not working for this. I have customized login page but added all code there too. This is my post and get method.

Please tell me what I am doing wrong here

   public virtual async Task OnGetAsync()
        {
            LoginInput = new LoginInputModel();
            if (!ErrorMessage.IsNullOrWhiteSpace())
            {
                Alerts.Danger(ErrorMessage);
            }
            Input = new PostInput();
            Forgot = new ForgotPasswordModel();

            EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin);
            IsSelfRegistrationEnabled = await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled);

            UseCaptcha = await UseCaptchaOnLoginAsync();

            if (IsExternalLoginOnly)
            {
                //return await ExternalLogin(vm.ExternalLoginScheme, returnUrl);
                throw new NotImplementedException();
            }

            IsLinkLogin = await VerifyLinkTokenAsync();
        }
 public virtual async Task<IActionResult> OnPostAsync(string action)
        {

            try
            {
                // ValidateModel();
                var blazorUrl = _configuration.GetSection("App")["RedirectAllowedUrls"];


                await IdentityOptions.SetAsync();

                ExternalProviders = await GetExternalProviders();

                EnableLocalLogin = await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin);
                IsSelfRegistrationEnabled = await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled);

                await ReplaceEmailToUsernameOfInputIfNeeds();

                IsLinkLogin = await VerifyLinkTokenAsync();

                var result = await SignInManager.PasswordSignInAsync(
                    LoginInput.UserNameOrEmailAddress,
                    LoginInput.Password,
                    LoginInput.RememberMe,
                    true
                );

                await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext
                {
                    Identity = IdentitySecurityLogIdentityConsts.Identity,
                    Action = result.ToIdentitySecurityLogAction(),
                    UserName = LoginInput.UserNameOrEmailAddress
                });

                if (result.RequiresTwoFactor)
                {
                    return RedirectToPage("./SendSecurityCode", new
                    {
                        returnUrl = ReturnUrl,
                        returnUrlHash = ReturnUrlHash,
                        rememberMe = LoginInput.RememberMe,
                        linkUserId = LinkUserId,
                        linkTenantId = LinkTenantId,
                        linkToken = LinkToken
                    });
                }

                if (result.IsLockedOut)
                {
                    Alerts.Warning(L["UserLockedOutMessage"]);
                    return Page();
                }

                if (result.IsNotAllowed)
                {
                    Alerts.Warning(L["LoginIsNotAllowed"]);
                    return Page();
                }

                if (!result.Succeeded)
                {
                    Alerts.Danger(L["InvalidUserNameOrPassword"]);
                    return Page();
                }

                //TODO: Find a way of getting user's id from the logged in user and do not query it again like that!
                var user = await UserManager.FindByNameAsync(LoginInput.UserNameOrEmailAddress) ??
                           await UserManager.FindByEmailAsync(LoginInput.UserNameOrEmailAddress);

                Debug.Assert(user != null, nameof(user) + " != null");

                if (IsLinkLogin)
                {
                    using (CurrentPrincipalAccessor.Change(await SignInManager.CreateUserPrincipalAsync(user)))
                    {
                        await IdentityLinkUserAppService.LinkAsync(new LinkUserInput
                        {
                            UserId = LinkUserId.Value,
                            TenantId = LinkTenantId,
                            Token = LinkToken
                        });
                    }
                }
                if (ReturnUrl == null && ReturnUrlHash == null)
                {
                    if (result.Succeeded)
                    {
                        return RedirectSafely(blazorUrl, ReturnUrlHash);
                    }
                 
            }
            }
           catch(Exception ex)
            {
                Logger.LogWarning("login"+ ex.InnerException.Message);

            }
            
            return RedirectSafely(ReturnUrl, ReturnUrlHash);
        }

Hello,

I tried what you want to do in my own project and it worked fine.

Here are my steps: 1-) I create a new file named test.css in wwwroot

2-) I change the MyProjectNameBundleContributor as below.

    public class Test123BundleContributor : IBundleContributor 
    { 
        public void AddScripts(BundleContext context) 
        { 
             
        } 
 
        public void AddStyles(BundleContext context) 
        { 
            context.Add("main.css"); 
            context.BundleDefinitions.ReplaceOne(x => x.Source == "_content/Volo.Abp.AspNetCore.Components.WebAssembly.Theming/libs/bootstrap/css/bootstrap.min.css",  
                new BundleDefinition 
                { 
                    Source = "test.css" 
                }); 
        } 
    } 

As you can see from the code, I removed bootstrap.min.css and added test.css instead.

You can access other sources here.

3-) Run the abp bundle -f command in the Blazor project 4-) Check the global.css in wwwroot

5-) Run the application.



Note: I understand that you have an urgency and this is perfectly normal, but you are not the only one we need to take care of so I think you will appreciate short-term (e.g. 1 day) delayed responses. Also, it would be much better if you provide a minimal reproducible example for this kind of urgent business.

Why is a minimally reproducible example necessary?

For example, when you were describing the first problem, you explained it as follows.

I have run abp bundle command so it's showing script and styles bundled and I can see changes in my index.html file as well but If I run site so in browser no changes are done like it's not reducing js or css calls.

That sounds pretty self-explanatory, I can repeat that.

In your next reply, you replied as follows.

I checked my development.json file as well so it 's empty also If I try to add my custom css or js files in bundlecontributor.cs class and removing same js or css from index.html page and run abp bundle so it's not updating global.js or global.css files.

That sounds pretty self-explanatory, also. However, now you say you replace a resource.

So, both can be repeated for themselves, but there is difference between the two definitions. What I understood when I read the first definition is different from what I understood when I read the second definition. (Maybe I got it wrong, but it doesn't matter who misunderstood. The important thing is to solve the problem.)

As a result, while trying to reproduce the problem, I interpret and answer according to my own understanding. I make an effort to understand the problem, but nevertheless, if I misunderstood, I am not able to give an immediate response to your urgent problem. This is why a minimally reproducible example is vital.

Thanks much for this answer!

Hello,

First of all, I assume that your appsettings.json file under wwwroot is as follows. I also think Bundle:Mode is not override by appsettings.development.json or otherwise.



After all this, I can say that I couldn't reproduce the problem.

global.css?_v=XXXXX

global.js?_v=XXXXX

I checked my development.json file as well so it 's empty also If I try to add my custom css or js files in bundlecontributor.cs class and removing same js or css from index.html page and run abp bundle so it's not updating global.js or global.css files.

Please suggest me what I am doing wrong here. Expecting early response!

Thanks,

Please do some needful

Hello,

First of all, I assume that your appsettings.json file under wwwroot is as follows. I also think Bundle:Mode is not override by appsettings.development.json or otherwise.



After all this, I can say that I couldn't reproduce the problem.

global.css?_v=XXXXX

global.js?_v=XXXXX

I checked my development.json file as well so it 's empty also If I try to add my custom css or js files in bundlecontributor.cs class and removing same js or css from index.html page and run abp bundle so it's not updating global.js or global.css files.

Please suggest me what I am doing wrong here. Expecting early response!

Thanks,

Please reply!

Is there anyone who can help me out!

whenever I post question I wait for whole day to get my answer sometimes it's can be urgent. Still this question is not assigned to anyone.

Please reply!

Is there anyone who can help me out!

Please reply!

Hi

I have run abp bundle command so it's showing script and styles bundled and I can see changes in my index.html file as well but If I run site so in browser no changes are done like it's not reducing js or css calls.

  • ABP Framework version: v4.4.3
  • UI type:Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

looks like you are missing a mandatory tool in your environment! first, check out this document https://docs.abp.io/en/commercial/latest/getting-started-setup-environment

After installing abp iibs I am getting this error on login button click.

First screen is working but if I click on login then getting above error

looks like you are missing a mandatory tool in your environment! first, check out this document https://docs.abp.io/en/commercial/latest/getting-started-setup-environment

let me try this

Showing 31 to 40 of 347 entries
Made with ❤️ on ABP v9.0.0-preview Updated on September 19, 2024, 10:13