public async Task <StatusData <AccountInternal> > GetUserInfo(string userNameOrEmailOrId)
        {
            var response = new StatusData <AccountInternal> {
                Status = SystemDbStatus.Selected
            };

            var user = await Task.Factory.StartNew(() => Client.UserService.getUserLoginInfo(userNameOrEmailOrId)).ConfigureAwait(false);

            if (user == null)
            {
                response.Status = SystemDbStatus.NotFound;
                return(response);
            }

            var userInfo = new AccountInternal
            {
                UserId             = Convert.ToInt32(user.UserId),
                UserName           = user.UserName,
                FirstName          = user.UserInfo.UserTypeId == (byte)SystemUserType.Person ? user.UserInfoPerson.FirstName + ' ' + user.UserInfoPerson.LastName : user.UserInforCompany.Name,
                ImageServerAddress = SystemConstants.ImageServerAddress.ToString(),
                UserGuid           = user.UserGUID,
                Email = user.Email
            };

            response.Status  = (SystemDbStatus)user.DbStatusCode;
            response.Data    = userInfo;
            response.Message = user.DbStatusMsg;
            return(response);
        }
Пример #2
0
        public async Task <StatusData <AccountInternal> > ForgotPassword(string userName)
        {
            var response = new StatusData <AccountInternal> {
                Status = SystemDbStatus.Updated
            };

            var user = await FirstOrDefaultAsync(x => (x.LoweredUserName == userName || x.LoweredEmail == userName)).ConfigureAwait(false);

            if (user == null)
            {
                response.Status = SystemDbStatus.NotFound;
                return(response);
            }

            var userGuid = Guid.NewGuid().ToString();
            var userInfo = new AccountInternal
            {
                UserId              = user.UserId,
                UserName            = user.UserName,
                UserGuid            = userGuid,
                FirstName           = user.UserInfo.UserTypeID == (byte)SystemUserType.Person ? user.UserInfo.UserInfoPerson.FirstName : user.UserInfo.UserInfoCompany.Name,
                ImageServerAddress  = SystemConstants.ImageServerAddress.ToString(),
                UrlRegistrationLink = new Uri(new Uri(SystemConstants.WebUrl.Value), "\\Account\\ResetPassword?qid=" + Encryptor.EncryptHelper("id=" + user.UserId) + "&authkey=" + HttpUtility.UrlEncode(userGuid) + "&isdirect=true".Replace("\\", "/")).ToString(),
                UrlVerificationLink = new Uri(new Uri(SystemConstants.WebUrl.Value), "\\Account\\ResetPassword?qid=" + Encryptor.EncryptHelper("id=" + user.UserId) + "&authkey=" + HttpUtility.UrlEncode(userGuid) + "&isdirect=false".Replace("\\", "/")).ToString(),
                //MobileUnlockCode = Encryptor.RandomString(4, "0123456789"),
                Email = user.LoweredEmail
            };

            user.UserGUID         = userGuid;
            user.LastActivityDate = DateTime.UtcNow;

            response.Data = userInfo;
            return(response);
        }
Пример #3
0
        private async Task <HttpResponseMessage> SignUpBusiness(SignUpRequestBusiness request)
        {
            var response = await _accountService.SignUpBusiness(request);

            if (response.Status.IsOperationSuccessful())
            {
                var registration = new AccountInternal
                {
                    Email               = request.Email,
                    FirstName           = request.CompanyName,
                    UserName            = request.UserName,
                    ImageServerAddress  = SystemConstants.ImageServerAddress.ToString(),
                    UrlRegistrationLink =
                        new Uri(new Uri(SystemConstants.WebUrl.Value), "\\Account\\Activation".Replace("\\", "/")).ToString(),
                    UrlVerificationLink =
                        new Uri(new Uri(SystemConstants.WebUrl.Value), "\\Account\\Activate".Replace("\\", "/")).ToString(),
                    UserGuid = response.Data.UserGuid,
                    UserId   = response.Data.UserId
                };

                var html = ViewRenderer.RenderView("~/Views/Home/OutMail/_RegistrationTemplatePartial.cshtml",
                                                   registration);
                Helper.SendMail(registration.Email, "Activation Mail", html,
                                bodyImages: new List <string> {
                    "~/Images/iLoop.png"
                });
            }
            return(Request.SystemResponse <string>(response.Status));
        }
        public async Task <StatusData <AccountInternal> > ForgotPassword(string userName)
        {
            var response = new StatusData <AccountInternal> {
                Status = SystemDbStatus.Updated
            };

            var user = await Task.Factory.StartNew(() => Client.UserService.getUserLoginInfo(userName)).ConfigureAwait(false);

            if (user == null)
            {
                response.Status = SystemDbStatus.NotFound;
                return(response);
            }

            var userGuid = await GetPasswordResetCode(user.UserId, user.UserName).ConfigureAwait(false);

            userGuid = userGuid.TrimEnd('\r', '\n');

            var userInfo = new AccountInternal
            {
                UserId              = Convert.ToInt32(user.UserId),
                UserName            = user.UserName,
                UserGuid            = userGuid,
                FirstName           = user.UserInfo.UserTypeId == (byte)SystemUserType.Person ? user.UserInfoPerson.FirstName : user.UserInforCompany.Name,
                ImageServerAddress  = SystemConstants.ImageServerAddress.ToString(),
                UrlRegistrationLink = new Uri(new Uri(SystemConstants.WebUrl.Value), "index.html#/confirm-email-reset/" + HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(user.UserName))) + "/" + HttpUtility.UrlEncode(userGuid) + "/true").ToString(),
                UrlVerificationLink = new Uri(new Uri(SystemConstants.WebUrl.Value), "index.html#/confirm-email-reset/" + HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(user.UserName))) + "/" + HttpUtility.UrlEncode(userGuid) + "/false").ToString(),
                Email = user.Email
            };

            // user.UserGUID = userGuid;
            // user.LastActivityDate = DateTime.UtcNow;

            response.Status = SystemDbStatus.Updated;
            response.Data   = userInfo;
            return(response);
        }
        private async Task <HttpResponseMessage> SignUpPerson(SignUpRequestPerson request)
        {
            var response = await _accountService.SignUpPerson(request);

            if (response.Status.IsOperationSuccessful())
            {
                var registration = new AccountInternal
                {
                    Email               = request.Email,
                    FirstName           = request.FirstName,
                    UserName            = request.UserName,
                    ImageServerAddress  = SystemConstants.ImageServerAddress.ToString(),
                    UrlRegistrationLink =
                        new Uri(new Uri(SystemConstants.WebUrl.Value),
                                "index.html#/activation/" +
                                HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(request.UserName))) + "/" +
                                HttpUtility.UrlEncode((Convert.ToBase64String(Encoding.UTF8.GetBytes(response.Data.UserGuid)))))
                        .ToString(),
                    UrlVerificationLink =
                        new Uri(new Uri(SystemConstants.WebUrl.Value),
                                "index.html#/activation/" +
                                HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(request.UserName))) + "/")
                        .ToString(),
                    UserGuid = response.Data.UserGuid,
                    UserId   = response.Data.UserId
                };

                var html = ViewRenderer.RenderView("~/Views/Home/OutMail/_RegistrationTemplatePartial.cshtml",
                                                   registration);
                Helper.SendMail(registration.Email, "Activation Mail", html,
                                bodyImages: new List <string> {
                    "~/Images/iLoop.png"
                });
            }
            return(Request.SystemResponse <string>(response.Status));
        }