Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "firnas"

Question

I have a mobile application that allows user registration. When registering the user from the API, I set the "User" role to the new user created. The user can log in to the mobile application once the "User" role is set.

If i try to log in to the angular web site using the credentials used to create the new user, the user can log in to the application. I need to disable this functionality. The mobile created users should not log in to the angular web application. The web application acts as the admin site.

How can i disable mobile created users from logging into the web application?

Question

Can you please let me know how to navigate from the angular UI to hangfire dashboard?

HI,

I have updated Iconize and Iconize.FontAwsome plugin to v 3.5 by following https://github.com/jsmarcus/Iconize

but my iOS app does not show icons but shows the test of the icon. ex : "fas-eye"

Android application works fine with icons.

Can I know what is the issue there ?

Hi,

I have a hangfire job which calls a class in the Core project. This class calls the settings manager to get a setting value.

string dealerNo = await _settingManager.GetSettingValueAsync(MyConstants.DealerNo);

This returns a empty string as the dealer no. Is there any configuration that needs to be done to get Settings manager to work with hangfire?

Hi,

I have a to register a hangfire recurrent job in the PostInitialize method in the module. The job class constructor should be resolved by dependancy injection. I have used the following code to register the reccurent job in the module.

JobStorage.Current = new SqlServerStorage(_appConfiguration.GetConnectionString("Default")); RecurringJob.AddOrUpdate<ISendNotificationJob>(x => x.SendDeviceUnlockNotification(), Cron.MinuteInterval(10));

How ever when the SendDeviceUnlockNotification method is called it throws a object disposed exception. Can anyone please help me on this.

public SendNotificationJob(IRepository&lt;Payment> paymentRepository

, IPasstimeDomainService passtimeDomainService , IAppCentre appCentre , UserManager userManager) { _paymentRepository = paymentRepository; _passtimeDomainService = passtimeDomainService; _appCentre = appCentre; _userManager = userManager;

    }

Hi, What is the best / feasible way to upgrade the ASP.NET ZERO project, as there could be multiple ways?

We have tried upgrading from 3.5 to 4.1 and getting number of errors. There are issues when running the Angular project, although there is no build errors in the backend project. Below is the screenshot of console while running the upgraded app.

We are trying to upgrade in 2 different ways.

  1. Upgrade Nuget packages on old project
  2. Merge code from old project to latest version of ASP.NET ZERO template

Please advise

When trying to login with external user i am getting "There is no such an entity. Entity type: OnePoint.Authorization.Users.User, id: 105" error. By default i activated the user to avoid email verification check. This works for normal user creation. However, the error is only for external user such as Facebook login.

I have also noticed that this issue does not occur in localhost even for external user login. Appreciated if anyone can help me on this. I have given code sample and logs.

[HttpPost]
        
public async Task<ExternalAuthenticateResultModel> ExternalAuthenticate([FromBody] ExternalAuthenticateModel model)
        
{
            try
            {
                var externalUser = await GetExternalUserInfo(model);

                var loginResult = await _logInManager.LoginAsync(new UserLoginInfo(model.AuthProvider, model.ProviderKey, model.AuthProvider), GetTenancyNameOrNull());

                switch (loginResult.Result)
                {
                    case AbpLoginResultType.Success:
                        {
                            var accessToken = CreateAccessToken(CreateJwtClaims(loginResult.Identity));

                            var returnUrl = model.ReturnUrl;

                            if (model.SingleSignIn.HasValue && model.SingleSignIn.Value && loginResult.Result == AbpLoginResultType.Success)
                            {
                                loginResult.User.SetSignInToken();
                                returnUrl = AddSingleSignInParametersToReturnUrl(model.ReturnUrl, loginResult.User.SignInToken, loginResult.User.Id, loginResult.User.TenantId);
                            }

                            return new ExternalAuthenticateResultModel
                            {
                                AccessToken = accessToken,
                                EncryptedAccessToken = GetEncrpyedAccessToken(accessToken),
                                ExpireInSeconds = (int)_configuration.Expiration.TotalSeconds,
                                ReturnUrl = returnUrl
                            };
                        }
                    case AbpLoginResultType.UnknownExternalLogin:
                        {
                            var newUser = await RegisterExternalUserAsync(externalUser);

                            //commented to implement the email sending
                            //TODO email sending
                            if (!newUser.IsActive)
                            {
                                return new ExternalAuthenticateResultModel
                                {
                                    WaitingForActivation = true
                                };
                            }

                            //Try to login again with newly registered user!
                            loginResult = await _logInManager.LoginAsync(new UserLoginInfo(model.AuthProvider, model.ProviderKey, model.AuthProvider), GetTenancyNameOrNull());



                            if (loginResult.Result != AbpLoginResultType.Success)
                            {
                                throw _abpLoginResultTypeHelper.CreateExceptionForFailedLoginAttempt(
                                    loginResult.Result,
                                    model.ProviderKey,
                                    GetTenancyNameOrNull()
                                );
                            }
                            else //login success
                            {
                                //TODO map user if possible
                                // bool isMapSuccess = await IsSocialUserMapSuccess(externalUser.Provider, externalUser.ProviderKey, externalUser.Name);
                            }

                            var accessToken = CreateAccessToken(CreateJwtClaims(loginResult.Identity));
                            return new ExternalAuthenticateResultModel
                            {
                                AccessToken = accessToken,
                                EncryptedAccessToken = GetEncrpyedAccessToken(accessToken),
                                ExpireInSeconds = (int)_configuration.Expiration.TotalSeconds
                            };
                        }
                    default:
                        {
                            throw _abpLoginResultTypeHelper.CreateExceptionForFailedLoginAttempt(
                                loginResult.Result,
                                model.ProviderKey,
                                GetTenancyNameOrNull()
                            );
                        }
                }
            }
            catch (Exception ex)
            {

                Logger.Error(ex.Message);
                throw new UserFriendlyException("cannot create external user");
            }
        
}

this is the external authentication method.its calling RegisterExternalUserAsync method.in that one its calling register user method.

public async Task<User> RegisterAsync(string name, string surname, string emailAddress, string userName, string plainPassword, bool isEmailConfirmed, string emailActivationLink)
        {
            CheckForTenant();
            CheckSelfRegistrationIsEnabled();

            var tenant = await GetActiveTenantAsync();
            var isNewRegisteredUserActiveByDefault = await SettingManager.GetSettingValueAsync<bool>(AppSettings.UserManagement.IsNewRegisteredUserActiveByDefault);

            await _userPolicy.CheckMaxUserCountAsync(tenant.Id);

            var user = new User
            {
                TenantId = tenant.Id,
                Name = name,
                Surname = surname,
                EmailAddress = emailAddress,
                IsActive = isNewRegisteredUserActiveByDefault,
                UserName = userName,
                IsEmailConfirmed = isEmailConfirmed,
                Roles = new List<UserRole>()
            };

            user.SetNormalizedNames();

            user.Password = _passwordHasher.HashPassword(user, plainPassword);
            var defaultRoles = await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync();

            if (defaultRoles!=null && defaultRoles.Count!=0)
            {
                foreach (var defaultRole in defaultRoles)
                {
                    user.Roles.Add(new UserRole(tenant.Id, user.Id, defaultRole.Id));
                } 
            }

            CheckErrors(await _userManager.CreateAsync(user));
            await CurrentUnitOfWork.SaveChangesAsync();

            if (!user.IsEmailConfirmed)
            {
                user.SetNewEmailConfirmationCode();
                await _userEmailer.SendEmailActivationLinkAsync(user, emailActivationLink);
            }

            //Notifications
            await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());
            await _appNotifier.WelcomeToTheApplicationAsync(user);
            await _appNotifier.NewUserRegisteredAsync(user);

            return user;
        }

Below is the log

INFO  2018-07-25 09:27:10,060 [10   ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method OnePoint.Web.Controllers.TokenAuthController.ExternalAuthenticate (OnePoint.Web.Core) with arguments (OnePoint.Web.Models.TokenAuth.ExternalAuthenticateModel) - ModelState is Valid
ERROR 2018-07-25 09:27:11,688 [10   ] oint.Web.Controllers.TokenAuthController - There is no such an entity. Entity type: OnePoint.Authorization.Users.User, id: 105
WARN  2018-07-25 09:27:11,735 [10   ] Mvc.ExceptionHandling.AbpExceptionFilter - cannot create external user
Abp.UI.UserFriendlyException: cannot create external user
   at OnePoint.Web.Controllers.TokenAuthController.<ExternalAuthenticate>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at lambda_method(Closure , Object )
   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__23.MoveNext()
Showing 11 to 17 of 17 entries