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

Activities of "bulutyonetim"

Hi,

Thanks for answer. What is best practice of overriding CreateAsync method of UserManager. I do not want my code be lost when I update my project to lateset Asp.net Zero in future.

Hi, Thanks.

Hi,

I need to get which properties of enitity is being update in domain updating event, I there anyway for this?

I also tired this way but no hope, userBeforeUpdate have updated values not the orginal values.

[UnitOfWork]
public void HandleEvent(EntityUpdatingEventData<AbpUserBase> eventData)
{
    using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant))
    {
        //Get all users
        IQueryable<User> allUser = _userRepository.GetAll();
        var userBeforeUpdate = allUser.FirstOrDefault(ua => ua.Id == eventData.Entity.Id  && (ua.UserName == eventData.Entity.UserName || ua.EmailAddress == eventData.Entity.EmailAddress));

        //user email is being activated
        if (userBeforeUpdate.IsEmailConfirmed != eventData.Entity.IsEmailConfirmed && userBeforeUpdate.EmailConfirmationCode != eventData.Entity.EmailConfirmationCode)
        {

        }
    }
}

Hi,

I tried to get what I needed with the help of domain events. But I have a problem.

Suppose this: When I create a User1 in tenant A, my domain activity is triggered. In the case of domain, I add the new user with the same attributes to the Default tenant. however, this action triggers my domain activities again.

I am having the same problem updating user information. For example, when I change the user's last name in Tenant A, my domain activity is triggered, so I update the user's last name in Tenant Default, but again this update repeats the triggers domain event.

Any solution to turn off the domain event in a section of the code? Or is there any way to get any information that shows me that the event was routed by the system and not the end user?

Here is my code for recreate user in default tenant:

 public virtual void HandleEvent(EntityCreatingEventData<AbpUserBase> eventData)
        {
            //If user is not being added to host or default tenant
            if (eventData.Entity.TenantId != null && eventData.Entity.TenantId != 1)
            {
                //Workining on default tenant
                using (_unitOfWorkManager.Current.SetTenantId(1))
                {
                    //Get all users of default tenant
                    IQueryable<User> allUser = _userRepository.GetAll();

                    //Get user with same email or username
                    var defaultTenantUser = allUser.FirstOrDefault(ua => ua.TenantId == 1 && (ua.UserName == eventData.Entity.UserName || ua.EmailAddress == eventData.Entity.EmailAddress));

                    //If user with same email or username is not available in default tenant
                    if (defaultTenantUser == null)
                    {
                        //add "User" Role to new user roles
                        var userRoles = new Collection<UserRole>();
                        var defaultRole = _roleRepository.FirstOrDefault(r => r.Name == Pudux.Authorization.Roles.StaticRoleNames.Tenants.User);
                        userRoles.Add(new UserRole(1, eventData.Entity.Id, defaultRole.Id));

                        var userToAdd = new User
                        {
                            TenantId = 1,
                            UserName = eventData.Entity.UserName,
                            Name = eventData.Entity.Name,
                            Surname = eventData.Entity.Surname,
                            EmailAddress = eventData.Entity.EmailAddress,
                            Password = eventData.Entity.Password,
                            PasswordResetCode = eventData.Entity.PasswordResetCode,
                            EmailConfirmationCode = eventData.Entity.EmailConfirmationCode,
                            IsActive = eventData.Entity.IsActive,
                            IsDeleted = eventData.Entity.IsDeleted,
                            IsEmailConfirmed = eventData.Entity.IsEmailConfirmed,
                            IsLockoutEnabled = eventData.Entity.IsLockoutEnabled,
                            IsPhoneNumberConfirmed = eventData.Entity.IsPhoneNumberConfirmed,
                            IsTwoFactorEnabled = eventData.Entity.IsTwoFactorEnabled,
                            NormalizedEmailAddress = eventData.Entity.EmailAddress.ToUpperInvariant(),
                            NormalizedUserName = eventData.Entity.UserName.ToUpperInvariant(),
                            Roles = userRoles,
                        };

                        //add user to default tenants
                        _userRepository.Insert(userToAdd);
                    }
                }
            }
        }

tnx

Hi,

Is it possible remove username from all authentication and authorization process? In other word, we just want email as authentication or authorization property?

thanks.

Hi,

Thanks for solution, Domain events are great feature.

Hi,

When creating user in tenant I need to create a user with same properties (username, email, password, ...) in default tenant if it is not already created and add it linked account of that user, Also When a user changes his password in any tenant, I need to change password of all users with same username in any tenant (in defualt tenant also).

what is the best practice to achieve this?

Why I need this, Assume this senario:

  • I have enabled multi tenant.
  • Person A has two account:
    • user1 Acoount on Tenant1
    • user2 Acoount on Tenant2 (user1 and user2 should have same username).

I need a way that Person A login into system (defualt tenant) then select tenant (from linked accounts) and continue working. In other mean I don't want to users select tenants before logging in to system.

Hi same Problem here:

D:\XXX\Git\Projects\XXX\XXXDemo\src\XXXDemo.Web.Host\XXXDemo.Web.Host.csproj : error : Cannot expand metadata in expression "$([MSBuild]::ValueOrDefault('%(FullPath)', '').StartsWith($([MSBuild]::EnsureTrailingSlash($(MSBuildProjectDirectory)))))". The item metadata "%(FullPath)" cannot be applied to the path "src\app\admin\dynamic-entity-parameters\entity-dynamic-parameter\entity-dynamic-parameter-value\entity-dynamic-parameter-value-manager\entity-dynamic-parameter-value-manager.component.html". Path: D:\XXX\Git\Projects\XXX\XXXDemo\src\XXXDemo.Web.Host\src\app\admin\dynamic-entity-parameters\entity-dynamic-parameter\entity-dynamic-parameter-value\entity-dynamic-parameter-value-manager\entity-dynamic-parameter-value-manager.component.html

exceeds the OS max path limit. The fully qualified file name must be less than 260 characters

. C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets

We had to decrease folders name or move project to uper floders but it would disrupt our folder structure.

What you (support team) recomend for this case?

Hi, I have a few question (problem) with social and external logins.

  1. Assume this scenario: Allow users to register to the system is disabled, external logins will does not work and users are receiving: Self user registration is disabled. Please contact the system administrator to register. error.

  2. Assume this scenario: Allow users to register to the system is enabled, I register a user with her/his Gmail via admin panel (Or user registered himself via normal registration form), then if user try to login with external logins (Google) will receive following error: Email '[email protected]' is already taken.

Generally sites allows this kind of scenarios. It should not matter how user has been registered.

One more thing according to Google Docs after user signed in via Google OAuth developer should Verify the integrity of the ID token. I couldn't find any code doing this. Can you also guide me about this part?

thanks

Showing 21 to 30 of 30 entries