Exemplo n.º 1
0
        protected virtual async Task <long> CreateUserAsync(CreateOrUpdateUserInput input)
        {
            input.User.UserName = input.User.UserName.Replace(" ", "");
            if (AbpSession.TenantId.HasValue)
            {
                await _userPolicy.CheckMaxUserCountAsync(AbpSession.GetTenantId());
            }

            var user = input.User.MapTo <User>(); //Passwords is not mapped (see mapping configuration)

            user.TenantId = AbpSession.TenantId;

            //Set password
            if (!input.User.Password.IsNullOrEmpty())
            {
                CheckErrors(await UserManager.PasswordValidator.ValidateAsync(input.User.Password));
            }
            else
            {
                input.User.Password = User.CreateRandomPassword();
            }

            user.Password = new PasswordHasher().HashPassword(input.User.Password);
            user.ShouldChangePasswordOnNextLogin = input.User.ShouldChangePasswordOnNextLogin;

            //Assign roles
            user.Roles = new Collection <UserRole>();
            foreach (var roleName in input.AssignedRoleNames)
            {
                var role = await _roleManager.GetRoleByNameAsync(roleName);

                user.Roles.Add(new UserRole(AbpSession.TenantId, user.Id, role.Id));
            }

            user.PhongBanId = input.User.PhongBanId;

            CheckErrors(await UserManager.CreateAsync(user));
            await CurrentUnitOfWork.SaveChangesAsync(); //To get new user's Id.

            //Notifications
            await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());

            await _appNotifier.WelcomeToTheApplicationAsync(user);

            //Send activation email
            if (input.SendActivationEmail)
            {
                user.SetNewEmailConfirmationCode();
                await _userEmailer.SendEmailActivationLinkAsync(user, input.User.Password);
            }

            return(user.Id);
        }
Exemplo n.º 2
0
        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);

            foreach (var defaultRole in await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync())
            {
                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);
        }
Exemplo n.º 3
0
        protected virtual async Task CreateUserAsync(CreateOrUpdateUserInput input)
        {
            if (AbpSession.TenantId.HasValue)
            {
                await _userPolicy.CheckMaxUserCountAsync(AbpSession.GetTenantId());
            }

            var user = ObjectMapper.Map <User>(input.User); //Passwords is not mapped (see mapping configuration)

            user.TenantId = AbpSession.TenantId;

            //Set password
            if (input.SetRandomPassword || input.User.Password.IsNullOrEmpty())
            {
                input.User.Password = User.CreateRandomPassword();
            }
            else
            {
                await UserManager.InitializeOptionsAsync(AbpSession.TenantId);

                foreach (var validator in _passwordValidators)
                {
                    CheckErrors(await validator.ValidateAsync(UserManager, user, input.User.Password));
                }
            }

            user.Password = _passwordHasher.HashPassword(user, input.User.Password);
            user.ShouldChangePasswordOnNextLogin = input.User.ShouldChangePasswordOnNextLogin;

            //Assign roles
            user.Roles = new Collection <UserRole>();
            foreach (var roleName in input.AssignedRoleNames)
            {
                var role = await _roleManager.GetRoleByNameAsync(roleName);

                user.Roles.Add(new UserRole(AbpSession.TenantId, user.Id, role.Id));
            }

            CheckErrors(await UserManager.CreateAsync(user));
            await CurrentUnitOfWork.SaveChangesAsync(); //To get new user's Id.

            //Notifications
            await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());

            await _appNotifier.WelcomeToTheApplicationAsync(user);

            //Organization Units
            await UserManager.SetOrganizationUnitsAsync(user, input.OrganizationUnits.ToArray());

            //Send activation email
            if (input.SendActivationEmail)
            {
                user.SetNewEmailConfirmationCode();
                await _userEmailer.SendEmailActivationLinkAsync(
                    user,
                    AppUrlService.CreateEmailActivationUrlFormat(AbpSession.TenantId),
                    input.User.Password
                    );
            }
        }
Exemplo n.º 4
0
        async Task CreateUser(EmployeeDto input)
        {
            if (AbpSession.TenantId.HasValue)
            {
                await _userPolicy.CheckMaxUserCountAsync(AbpSession.GetTenantId());
            }

            var user = new User
            {
                Name         = new LocalizedText(input.FullName)["en"],
                Surname      = new LocalizedText(input.FullName)["en"],
                UserName     = input.NationalId,
                EmailAddress = input.Email,
                TenantId     = AbpSession.TenantId,
            };


            user.Password = _passwordHasher.HashPassword(user, input.NationalId);
            user.ShouldChangePasswordOnNextLogin = true;

            //Assign roles
            user.Roles = new Collection <UserRole>();
            var role = await _roleManager.GetRoleByNameAsync(StaticRoleNames.Tenants.User);

            user.Roles.Add(new UserRole(AbpSession.TenantId, user.Id, role.Id));


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

            //Notifications
            await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());

            await _appNotifier.WelcomeToTheApplicationAsync(user);
        }
        private async Task CreateUserAsync(ImportUserDto input)
        {
            var tenantId = CurrentUnitOfWork.GetTenantId();

            if (tenantId.HasValue)
            {
                await _userPolicy.CheckMaxUserCountAsync(tenantId.Value);
            }

            var user = _objectMapper.Map <User>(input); //Passwords is not mapped (see mapping configuration)

            user.Password = input.Password;
            user.TenantId = tenantId;

            if (!input.Password.IsNullOrEmpty())
            {
                await UserManager.InitializeOptionsAsync(tenantId);

                foreach (var validator in _passwordValidators)
                {
                    (await validator.ValidateAsync(UserManager, user, input.Password)).CheckErrors();
                }

                user.Password = _passwordHasher.HashPassword(user, input.Password);
            }

            user.Roles = new List <UserRole>();
            var roleList = _roleManager.Roles.ToList();

            foreach (var roleName in input.AssignedRoleNames)
            {
                var correspondingRoleName = GetRoleNameFromDisplayName(roleName, roleList);
                var role = await _roleManager.GetRoleByNameAsync(correspondingRoleName);

                user.Roles.Add(new UserRole(tenantId, user.Id, role.Id));
            }

            (await UserManager.CreateAsync(user)).CheckErrors();
        }
Exemplo n.º 6
0
        public virtual async Task <ActionResult> Register(RegisterViewModel model)
        {
            try
            {
                CheckSelfRegistrationIsEnabled();

                if (!model.IsExternalLogin && UseCaptchaOnRegistration())
                {
                    var recaptchaHelper = this.GetRecaptchaVerificationHelper();
                    if (recaptchaHelper.Response.IsNullOrEmpty())
                    {
                        throw new UserFriendlyException(L("CaptchaCanNotBeEmpty"));
                    }

                    if (recaptchaHelper.VerifyRecaptchaResponse() != RecaptchaVerificationResult.Success)
                    {
                        throw new UserFriendlyException(L("IncorrectCaptchaAnswer"));
                    }
                }

                if (!_multiTenancyConfig.IsEnabled)
                {
                    model.TenancyName = Tenant.DefaultTenantName;
                }
                else if (model.TenancyName.IsNullOrEmpty())
                {
                    throw new UserFriendlyException(L("TenantNameCanNotBeEmpty"));
                }

                CurrentUnitOfWork.SetTenantId(null);

                var tenant = await GetActiveTenantAsync(model.TenancyName);

                CurrentUnitOfWork.SetTenantId(tenant.Id);

                if (!await SettingManager.GetSettingValueForTenantAsync <bool>(AppSettings.UserManagement.AllowSelfRegistration, tenant.Id))
                {
                    throw new UserFriendlyException(L("SelfUserRegistrationIsDisabledMessage_Detail"));
                }

                await _userPolicy.CheckMaxUserCountAsync(tenant.Id);

                //Getting tenant-specific settings
                var isNewRegisteredUserActiveByDefault = await SettingManager.GetSettingValueForTenantAsync <bool>(AppSettings.UserManagement.IsNewRegisteredUserActiveByDefault, tenant.Id);

                var isEmailConfirmationRequiredForLogin = await SettingManager.GetSettingValueForTenantAsync <bool>(AbpZeroSettingNames.UserManagement.IsEmailConfirmationRequiredForLogin, tenant.Id);

                var user = new User
                {
                    TenantId     = tenant.Id,
                    Name         = model.Name,
                    Surname      = model.Surname,
                    EmailAddress = model.EmailAddress,
                    IsActive     = isNewRegisteredUserActiveByDefault
                };

                ExternalLoginInfo externalLoginInfo = null;
                if (model.IsExternalLogin)
                {
                    externalLoginInfo = await _authenticationManager.GetExternalLoginInfoAsync();

                    if (externalLoginInfo == null)
                    {
                        throw new ApplicationException("Can not external login!");
                    }

                    user.Logins = new List <UserLogin>
                    {
                        new UserLogin
                        {
                            LoginProvider = externalLoginInfo.Login.LoginProvider,
                            ProviderKey   = externalLoginInfo.Login.ProviderKey,
                            TenantId      = tenant.Id
                        }
                    };

                    model.UserName = model.EmailAddress;
                    model.Password = Managers.Users.User.CreateRandomPassword();

                    if (string.Equals(externalLoginInfo.Email, model.EmailAddress, StringComparison.InvariantCultureIgnoreCase))
                    {
                        user.IsEmailConfirmed = true;
                    }
                }
                else
                {
                    if (model.UserName.IsNullOrEmpty() || model.Password.IsNullOrEmpty())
                    {
                        throw new UserFriendlyException(L("FormIsNotValidMessage"));
                    }
                }

                user.UserName = model.UserName;
                user.Password = new PasswordHasher().HashPassword(model.Password);

                user.Roles = new List <UserRole>();
                foreach (var defaultRole in await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync())
                {
                    user.Roles.Add(new UserRole(tenant.Id, user.Id, defaultRole.Id));
                }

                CheckErrors(await _userManager.CreateAsync(user));
                await _unitOfWorkManager.Current.SaveChangesAsync();

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

                //Notifications
                await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());

                await _appNotifier.WelcomeToTheApplicationAsync(user);

                await _appNotifier.NewUserRegisteredAsync(user);

                //Directly login if possible
                if (user.IsActive && (user.IsEmailConfirmed || !isEmailConfirmationRequiredForLogin))
                {
                    AbpLoginResult <Tenant, User> loginResult;
                    if (externalLoginInfo != null)
                    {
                        loginResult = await _logInManager.LoginAsync(externalLoginInfo.Login, tenant.TenancyName);
                    }
                    else
                    {
                        loginResult = await GetLoginResultAsync(user.UserName, model.Password, tenant.TenancyName);
                    }

                    if (loginResult.Result == AbpLoginResultType.Success)
                    {
                        await SignInAsync(loginResult.User, loginResult.Identity);

                        return(Redirect(Url.Action("Index", "Application")));
                    }

                    Logger.Warn("New registered user could not be login. This should not be normally. login result: " + loginResult.Result);
                }

                return(View("RegisterResult", new RegisterResultViewModel
                {
                    TenancyName = tenant.TenancyName,
                    NameAndSurname = user.Name + " " + user.Surname,
                    UserName = user.UserName,
                    EmailAddress = user.EmailAddress,
                    IsActive = user.IsActive,
                    IsEmailConfirmationRequired = isEmailConfirmationRequiredForLogin
                }));
            }
            catch (UserFriendlyException ex)
            {
                ViewBag.IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled;
                ViewBag.UseCaptcha            = !model.IsExternalLogin && UseCaptchaOnRegistration();
                ViewBag.ErrorMessage          = ex.Message;
                ViewBag.ErrorDetails          = ex.Details;

                return(View("Register", model));
            }
        }
        protected virtual async Task CreateUserAsync(CreateOrUpdateUserInput input)
        {
            if (AbpSession.TenantId.HasValue)
            {
                await _userPolicy.CheckMaxUserCountAsync(AbpSession.GetTenantId());
            }

            var user = ObjectMapper.Map <User>(input.User); //Passwords is not mapped (see mapping configuration)

            user.TenantId = AbpSession.TenantId;

            //Set password
            if (!input.User.Password.IsNullOrEmpty())
            {
                await UserManager.InitializeOptionsAsync(AbpSession.TenantId);

                foreach (var validator in _passwordValidators)
                {
                    CheckErrors(await validator.ValidateAsync(UserManager, user, input.User.Password));
                }
            }
            else
            {
                input.User.Password = User.CreateRandomPassword();
            }

            user.Password = _passwordHasher.HashPassword(user, input.User.Password);
            user.ShouldChangePasswordOnNextLogin = input.User.ShouldChangePasswordOnNextLogin;

            //Assign roles
            user.Roles = new Collection <UserRole>();
            foreach (var roleName in input.AssignedRoleNames)
            {
                var role = await _roleManager.GetRoleByNameAsync(roleName);

                user.Roles.Add(new UserRole(AbpSession.TenantId, user.Id, role.Id));
            }

            CheckErrors(await UserManager.CreateAsync(user));
            await CurrentUnitOfWork.SaveChangesAsync(); //To get new user's Id.

            _friendshipRepository.Insert(new Friendship(new Abp.UserIdentifier(AbpSession.TenantId, user.Id), new Abp.UserIdentifier(null, 1), "Default", "admin", null, FriendshipState.Accepted));

            if (AbpSession.TenantId.HasValue)
            {
                var curentTenant = await TenantManager.GetByIdAsync((int)AbpSession.TenantId);

                var tenantAdmin = (await UserManager.GetUsersInRoleAsync("Admin")).FirstOrDefault();
                if (tenantAdmin != null)
                {
                    _friendshipRepository.Insert(new Friendship(new Abp.UserIdentifier(AbpSession.TenantId, user.Id), new Abp.UserIdentifier(AbpSession.TenantId, tenantAdmin.Id), curentTenant.TenancyName, tenantAdmin.Name, null, FriendshipState.Accepted));
                }
            }

            //Notifications
            await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());

            await _appNotifier.WelcomeToTheApplicationAsync(user);

            //Organization Units
            await UserManager.SetOrganizationUnitsAsync(user, input.OrganizationUnits.ToArray());

            //Send activation email
            if (input.SendActivationEmail)
            {
                user.SetNewEmailConfirmationCode();
                await _userEmailer.SendEmailActivationLinkAsync(
                    user,
                    AppUrlService.CreateEmailActivationUrlFormat(AbpSession.TenantId),
                    input.User.Password
                    );
            }
        }
        public async Task <User> RegisterAsync(string name, string surname, string emailAddress, string userName, string plainPassword, string taxId, string serviceType, string npi, string specialty, string primaryContact, string address, string city, string state, string zip, bool isEmailConfirmed, string emailActivationLink)
        {
            bool isActive = false;

            CheckForTenant();
            CheckSelfRegistrationIsEnabled();

            var tenant = await GetActiveTenantAsync();

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

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://10.5.1.61:5000/api/eligibility_af/provider");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response = await client.GetAsync("?tin=" + taxId);

            if (response.IsSuccessStatusCode)
            {
                string  json    = response.Content.ReadAsStringAsync().Result;
                JObject results = JObject.Parse(json);
                if (results.Count > 0)
                {
                    isActive = true;
                }
            }
            if (surname == null)
            {
                surname = "None";
            }

            await _userPolicy.CheckMaxUserCountAsync(tenant.Id);

            var user = new User
            {
                TenantId         = tenant.Id,
                Name             = name,
                Surname          = surname,
                EmailAddress     = emailAddress,
                IsActive         = isActive,
                UserName         = userName,
                TaxId            = taxId,
                ServiceType      = serviceType,
                Npi              = npi,
                Specialty        = specialty,
                PrimaryContact   = primaryContact,
                Address          = address,
                City             = city,
                State            = state,
                Zip              = zip,
                IsEmailConfirmed = isEmailConfirmed,
                Roles            = new List <UserRole>()
            };

            user.SetNormalizedNames();

            user.Password = _passwordHasher.HashPassword(user, plainPassword);

            foreach (var defaultRole in await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync())
            {
                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);
        }
Exemplo n.º 9
0
        protected virtual async Task CreateUserAsync(CreateOrUpdateUserInput input)
        {
            if (AbpSession.TenantId.HasValue)
            {
                await _userPolicy.CheckMaxUserCountAsync(AbpSession.GetTenantId());
            }
            var fingerCode = Convert.ToInt32(input.User.FingerCode);
            var machineId  = input.User.MachineId;
            var uploadUser = input.User.UploadUser;
            var userImage  = input.User.UserImage;
            var user       = ObjectMapper.Map <User>(input.User); //Passwords is not mapped (see mapping configuration)

            user.TenantId = AbpSession.TenantId;

            //Set password
            if (input.SetRandomPassword)
            {
                var randomPassword = await _userManager.CreateRandomPassword();

                user.MobilePassword = EnryptString(randomPassword);
                user.Password       = _passwordHasher.HashPassword(user, randomPassword);
                input.User.Password = randomPassword;
            }
            else if (!input.User.Password.IsNullOrEmpty())
            {
                await UserManager.InitializeOptionsAsync(AbpSession.TenantId);

                foreach (var validator in _passwordValidators)
                {
                    CheckErrors(await validator.ValidateAsync(UserManager, user, input.User.Password));
                }
                user.MobilePassword = EnryptString(input.User.Password);
                user.Password       = _passwordHasher.HashPassword(user, input.User.Password);
            }

            user.ShouldChangePasswordOnNextLogin = input.User.ShouldChangePasswordOnNextLogin;

            //Assign roles
            user.Roles = new Collection <UserRole>();
            foreach (var roleName in input.AssignedRoleNames)
            {
                var role = await _roleManager.GetRoleByNameAsync(roleName);

                user.Roles.Add(new UserRole(AbpSession.TenantId, user.Id, role.Id));
            }

            //Assign Locations
            user.Locations = new Collection <UserLocation>();
            foreach (var assignedLocation in input.AssignedLocations)
            {
                var locationToAdd = await _locationRepository.FirstOrDefaultAsync(x => x.Id == assignedLocation.LocationId);

                user.Locations.Add(new UserLocation(user.Id, locationToAdd.Id, assignedLocation.FromDate, assignedLocation.ToDate));
            }

            CheckErrors(await UserManager.CreateAsync(user));
            await CurrentUnitOfWork.SaveChangesAsync(); //To get new user's Id.

            //Notifications
            await _notificationSubscriptionManager.SubscribeToAllAvailableNotificationsAsync(user.ToUserIdentifier());

            await _appNotifier.WelcomeToTheApplicationAsync(user);

            //Organization Units
            await UserManager.SetOrganizationUnitsAsync(user, input.OrganizationUnits.ToArray());

            //Send activation email
            if (input.SendActivationEmail)
            {
                user.SetNewEmailConfirmationCode();
                await _userEmailer.SendEmailActivationLinkAsync(
                    user,
                    AppUrlService.CreateEmailActivationUrlFormat(AbpSession.TenantId),
                    input.User.Password
                    );
            }

            //add user shifts
            //foreach (var userShiftModel in input.User.UserShifts)
            //{
            //    //add user shift
            //    await _userShiftRepository.InsertAsync(ObjectMapper.Map<UserShift>(userShiftModel.UserShift));
            //}
            foreach (var userShiftModel in input.User.OverrideShifts)
            {
                //add user shift
                await _overrideShiftRepository.InsertAsync(ObjectMapper.Map <OverrideShift>(userShiftModel.OverrideShift));
            }

            //add user to machine
            var userToUpload = new UploadMachineUserInput();

            userToUpload.Person          = new Person();
            userToUpload.MachineData     = new MachineData();
            userToUpload.Person.UserCode = fingerCode;
            var machine = await _machineRepository.FirstOrDefaultAsync(x => x.Id == machineId);

            userToUpload.MachineData.IP   = machine.IpAddress;
            userToUpload.MachineData.SN   = machine.SubNet;
            userToUpload.MachineData.Port = machine.Port;

            var inputJson = new StringContent(
                System.Text.Json.JsonSerializer.Serialize(userToUpload, new System.Text.Json.JsonSerializerOptions()), System.Text.Encoding.UTF8, "application/json");
            var client   = _clientFactory.CreateClient();
            var response = await client.PostAsync(_appConfiguration["Machine:uploadUserAPI"], inputJson);

            if (response.IsSuccessStatusCode)
            {
                using (var responseStream = await response.Content.ReadAsStreamAsync())
                {
                    await System.Text.Json.JsonSerializer.DeserializeAsync <string>(responseStream);
                }

                var downloadImageInput = new DownloadImageInput();
                var clearImage         = userImage.Split(",").ToList <string>();
                downloadImageInput.Datas       = Convert.FromBase64String(clearImage[1]);
                downloadImageInput.MachineData = userToUpload.MachineData;
                downloadImageInput.UserCode    = userToUpload.Person.UserCode;
                await UploadImage(downloadImageInput);
            }
        }
Exemplo n.º 10
0
        private async Task CreateUserAsync(ImportUserDto input)
        {
            var tenantId = CurrentUnitOfWork.GetTenantId();

            if (tenantId.HasValue)
            {
                await _userPolicy.CheckMaxUserCountAsync(tenantId.Value);
            }

            var user = _objectMapper.Map <User>(input);    //Passwords is not mapped (see mapping configuration)

            //shift
            var shift = await _shiftRepository.FirstOrDefaultAsync(x => x.NameAr == input.ShiftName ||
                                                                   x.NameEn == input.ShiftName ||
                                                                   x.Code == input.ShiftName);

            if (shift != null)
            {
                user.ShiftId = shift.Id;
            }

            //unit
            var unit = await _organizationUnitRepository.FirstOrDefaultAsync(x => x.DisplayName == input.Department);

            if (unit != null)
            {
                user.OrganizationUnitId = (int)unit.Id;
            }

            user.Password = input.Password;
            user.TenantId = tenantId;

            if (!input.Password.IsNullOrEmpty())
            {
                await UserManager.InitializeOptionsAsync(tenantId);

                foreach (var validator in _passwordValidators)
                {
                    (await validator.ValidateAsync(UserManager, user, input.Password)).CheckErrors();
                }

                user.Password = _passwordHasher.HashPassword(user, input.Password);
            }

            user.Roles = new List <UserRole>();
            var roleList = _roleManager.Roles.ToList();

            foreach (var roleName in input.AssignedRoleNames)
            {
                var correspondingRoleName = GetRoleNameFromDisplayName(roleName, roleList);
                var role = await _roleManager.GetRoleByNameAsync(correspondingRoleName);

                user.Roles.Add(new UserRole(tenantId, user.Id, role.Id));
            }

            var currentUser = await _userRepository.FirstOrDefaultAsync(x => x.CivilId == input.CivilId);

            if (currentUser != null)
            {
                currentUser.ShiftId            = user.ShiftId;
                currentUser.OrganizationUnitId = user.OrganizationUnitId;
                currentUser.FingerCode         = user.FingerCode;
                currentUser.Password           = user.Password;

                await UserManager.UpdateAsync(currentUser);
            }

            else
            {
                (await UserManager.CreateAsync(user)).CheckErrors();
            }
        }