Beispiel #1
0
        public void CreateUser(string username, string name, string roleId, string phone, int boundaryId)
        {
            //Act
            bool status = repository.CreateUser(username, name, phone, roleId, boundaryId, true);

            //Assert
            Assert.True(status);
        }
        private void CreateUserForTask(string userName, string email)
        {
            var account = new AccountModel
            {
                IsActivate  = true,
                AccountName = userName,
                Email       = email,
            };

            IdentityRepository.CreateUser(account, "!@#$%^&*()");
        }
Beispiel #3
0
        public BaseResponse CreateUser(CreateUserRequest request)
        {
            var accountModel = new AccountModel
            {
                IsActivate  = true,
                AccountName = request.UserName,
                Description = request.Description,
                Email       = request.Email,
                Note        = request.Note
            };
            var baseRoles = (request.BaseRoles ?? Enumerable.Empty <string>()).ToArray();

            IdentityRepository.CreateUser(accountModel, "!@#$%^&*()");
            IdentityRepository.AddUserInRoles(request.UserName, baseRoles);
            return(BaseResponse.Ok());
        }
Beispiel #4
0
        public bool SaveUser(string userEmail, string name, string userPhone, string roleId, bool isEnable, int BoundaryId)
        {
            #region variables
            bool        isEmailSent = false;
            EmailHelper helper;
            bool        IsComplete  = false;
            string      htmlmessage = null;
            string      callbackUrl = null;
            string      loginUrl    = baseUrlIdentityServer + "/ui/login";
            string      Token       = Guid.NewGuid().ToString();
            DateTime    ExpiryDate  = DateTime.Now.AddDays(1);
            string      UserName    = null;
            #endregion

            bool   isUserCreated = _identityRepository.CreateUser(userEmail, name, userPhone, roleId, BoundaryId, isEnable);
            string redirectUri   = GenericHelper.EncodeUrl(GetRedirectUrl(roleId));
            if (isUserCreated)
            {
                #region Send Email to User to activate account
                UserName    = _identityRepository.GetUserNameByEmail(userEmail.Trim());
                callbackUrl = string.Format("{0}/ui/ResetPassword?TokenKey={1}&redirectUri={2}", baseUrlIdentityServer, Token, redirectUri);

                if (_identityRepository.SaveToken(userEmail.Trim(), Token, ExpiryDate, IsComplete))
                {
                    htmlmessage = String.Format("<b>Hi {0}.</b><br/><br/>You have been invited to the BitzerIoc system." +
                                                "<br/><br/>User name = {0} <br/><br/>" +
                                                "To activate your account and create a password please <a href='{1}' > click here. </a>" +
                                                "<br/><br/>Best regards.",
                                                UserName, callbackUrl, loginUrl);


                    helper = new EmailHelper(userEmail.Trim(), EmailConstants.From, "Setup password request", "", htmlmessage, null);

                    isEmailSent = helper.SendEmailAsync().Result;
                }
                #endregion
            }
            return(isEmailSent);
        }