示例#1
0
        public async Task <IActionResult> Create(InviteEditModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    PersonView person = await this.personService.GetCurrentPersonViewAsync();

                    InviteCode code = await this.inviteService.InsertAsync(model, person);

                    return(this.Json(AjaxResult.CreateByContext(code)));
                }
                catch (ModelException ex)
                {
                    return(this.Json(ex.ToAjaxResult()));
                }
                catch (Exception ex)
                {
                    return(this.Json(AjaxResult.CreateByMessage(ex.Message, false)));
                }
            }
            else
            {
                return(this.Json(ModelState.ToAjaxResult()));
            }
        }
        public ActionResult GenerateInvite(string email)
        {
            // Only allow admins to submit a new code
            if (MembershipAuth.IsAdmin(HttpContext.Request))
            {
                // Generate the invite code
                Random rand = new Random();
                string code = StringManipulator.CreateInviteCode(rand.Next(58, 65));

                // Get information from database to populate the invite
                string userName  = MembershipAuth.GetCurrentUser(HttpContext.Request);
                int    orgID     = db.Users.SingleOrDefault(u => u.Email == userName).OrganizationID;
                int    createdBy = db.Users.SingleOrDefault(u => u.Email == userName).Id;

                // Create new invite code
                InviteCode invite = new InviteCode
                {
                    Code           = code,
                    DateCreated    = DateTime.Now,
                    OrganizationID = orgID,
                    IsExpired      = false,
                    CreatedBy      = createdBy,
                    SentTo         = email
                };

                // Add and commit to database
                db.InviteCodes.Add(invite);
                db.SaveChanges();
            }

            // Return error screen
            return(RedirectToAction("Error", "Error", new { error = 3 }));
        }
示例#3
0
        /// <summary>
        /// 插入邀请码
        /// </summary>
        public async Task <InviteCode> InsertAsync(InviteEditModel model, PersonView person)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (person == null)
            {
                throw new ArgumentNullException(nameof(person));
            }
            using (var work = this.dbFactory.StartWork())
            {
                if (await work.InviteCode.IsExistCodeAsync(model.Code))
                {
                    throw new ModelException(nameof(model.Code), "该邀请码已存在");
                }
                else
                {
                    InviteCode code = new InviteCode {
                        Code = model.Code, Id = GuidHelper.CreateSequential(), PersonId = person.Id
                    };
                    await work.InviteCode.InsertAsync(code);

                    return(code);
                }
            }
        }
示例#4
0
 /// <summary>
 /// Удаляет инвайт и пользователя для которого он создан
 /// </summary>
 /// <param name="invite"></param>
 private void DeleteInviteAndUser(InviteCode invite)
 {
     if (!UserRep.DeleteUserByEmail(invite.User.UserName))
     {
         throw new NotImplementedException();
     }
 }
示例#5
0
        public void Invoke(string[] args)
        {
            var options = new OptionSet();

            options.Add(
                "?|help",
                "Show help information.",
                x => HelpUtility.WriteHelpInformation(this, options)
                );

            bool matchFound = false;

            if (args != null)
            {
                try
                {
                    var extra = options.Parse(args);
                    matchFound = args.Length != extra.Count;
                }
                catch (OptionException ex)
                {
                    CommandResult.WriteLine(ex.Message);
                }
            }

            if (!matchFound)
            {
                if (args.IsNullOrEmpty())
                {
                    CommandResult.WriteLine("You must supply a username.");
                }
                else if (args.Length == 1)
                {
                    var username = args[0];
                    if (!_dataBucket.UserRepository.CheckUserExists(username))
                    {
                        var    random = new Random();
                        string code   = random.Next(1 << 16).ToString("X4")
                                        + random.Next(1 << 16).ToString("X4")
                                        + random.Next(1 << 16).ToString("X4")
                                        + random.Next(1 << 16).ToString("X4");
                        var inviteCode = new InviteCode
                        {
                            Code     = code,
                            Username = username
                        };
                        _dataBucket.InviteCodeRepository.AddInviteCode(inviteCode);
                        _dataBucket.SaveChanges();
                        CommandResult.WriteLine("Invite Code: {0}", code);
                    }
                    else
                    {
                        CommandResult.WriteLine("That username already exists.");
                    }
                }
            }
        }
        /// <summary>
        /// Формирует InviteEmailModel из <paramref name="invite"/>
        /// </summary>
        /// <param name="invite"></param>
        public static InviteEmailModel GetInviteEmailModel(InviteCode invite)
        {
            InviteEmailModel toReturn = new InviteEmailModel();

            toReturn.MailTo.Add(invite.User.UserName);
            toReturn.Caption = "Invite";
            toReturn.Link    = invite.Code;
            return(toReturn);
        }
    //解析配置
    public override void parseConfig(string str)
    {
        InviteCode be = new InviteCode(str);

        if (list == null)
        {
            list = new List <InviteCode> ();
        }
        list.Add(be);
    }
示例#8
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (header_ != null)
            {
                hash ^= Header.GetHashCode();
            }
            if (UserName.Length != 0)
            {
                hash ^= UserName.GetHashCode();
            }
            if (Password.Length != 0)
            {
                hash ^= Password.GetHashCode();
            }
            if (ValidCode.Length != 0)
            {
                hash ^= ValidCode.GetHashCode();
            }
            if (ValidId.Length != 0)
            {
                hash ^= ValidId.GetHashCode();
            }
            if (PhoneNumber.Length != 0)
            {
                hash ^= PhoneNumber.GetHashCode();
            }
            if (DeviceCode.Length != 0)
            {
                hash ^= DeviceCode.GetHashCode();
            }
            if (InviteCode.Length != 0)
            {
                hash ^= InviteCode.GetHashCode();
            }
            if (LoginType != 0)
            {
                hash ^= LoginType.GetHashCode();
            }
            if (Register != false)
            {
                hash ^= Register.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#9
0
        public async Task <ActionResult <InviteCodeApiDto> > PostInviteCodeNoLimit()
        {
            var currentUser = await _userManager.GetUserAsync(User);

            var code = new InviteCode
            {
                Code     = GenerateCode(),
                IssuedBy = currentUser
            };
            await _context.InviteCodes.AddAsync(code);

            await _context.SaveChangesAsync();

            return(_mapper.Map <InviteCode, InviteCodeApiDto>(code));
        }
示例#10
0
        //
        // GET: /MyCenter/
        /// <summary>
        /// 授权码
        /// </summary>
        /// <returns></returns>
        public ActionResult InviteCode()
        {
            ViewData["user"] = C_UserVM.GetVMByID(CurrentUser.ID);
            InviteCode code = WeModels.InviteCode.GetListByUserName(CurrentUser.UserName, "授权");

            if (code == null || code.ValidDat < DateTime.Now)
            {
                code          = new InviteCode();
                code.UserName = CurrentUser.UserName;
                code.ValidDat = DateTime.Now.AddMinutes(20);//二十分钟有效
                code.Type     = "授权";
                code.ID       = code.InsertAndReturnIdentity();
            }
            ViewData["code"] = code;
            return(View());
        }
示例#11
0
    //根据标签页获取相应的数据,用于邀请码与互粉
    public List <InviteCode> getAllInviteCodeByTapType(int _type)
    {
        List <InviteCode> ic = InviteCodeConfigManager.Instance.getInviteCode();

        List <InviteCode> newic  = new List <InviteCode>();
        InviteCode        icItem = null;

        for (int j = 0; j < ic.Count; j++)
        {
            if (StringKit.toInt(ic[j].tapType) == _type)
            {
                icItem = ic[j];
            }
            newic.Add(icItem);
        }
        return(newic);
    }
        public async Task <IHttpActionResult> PostInvite(WebApiSucksSoMuch inviteEmail)
        {
            if (inviteEmail.Email == "")
            {
                string error = "noEmail";
                return(Ok(error));
            }

            var user = db.Users.Find(User.Identity.GetUserId());

            InviteCode code = new InviteCode();

            var invite = db.Invitation.FirstOrDefault(i => i.InvitedEmail == inviteEmail.Email && i.HouseholdId == user.HouseholdId);

            if (invite == null)
            {
                invite = new Invitaton()
                {
                    Code         = code.CreateCode(),
                    HouseholdId  = user.HouseholdId,
                    InvitedEmail = inviteEmail.Email
                };

                db.Invitation.Add(invite);
            }

            var invitedUserExists = db.Users.Any(u => u.Email == inviteEmail.Email);

            //var url = invitedUserExists ? Url.Route("Go to join view", "") : Url.Route("Go to register and join view", "");

            var mailer = new EmailService();

            var message = new IdentityMessage()
            {
                Subject     = "You've been invited",
                Destination = inviteEmail.Email,
                Body        = "You've been invited to join " + user.DisplayName + "'s household. This is your join code: " + invite.Code
            };

            await db.SaveChangesAsync();

            await mailer.SendAsync(message);

            return(Ok(invite));
        }
示例#13
0
    public void initUI(InviteCode _ic, int _index)
    {
        if (labelJindu.gameObject.activeSelf)
        {
            labelJindu.gameObject.SetActive(false);
        }
        win = fatherWindow as InviteCodeWindow;

        if (_ic == null)
        {
            return;
        }
        ic    = _ic;
        index = _index;
        ShowAward();
        ShowJindu();
        isReceived();
    }
        public static async Task <ValidationResult> CheckInviteCodeAlreadyExist(InviteCode inviteCode,
                                                                                IUnitOfWork unitOfWork)
        {
            if (inviteCode is null)
            {
                throw new ArgumentNullException();
            }

            var exists = await unitOfWork.InviteCodes.InviteCodeExistsAsync(inviteCode.Code);

            if (exists)
            {
                return(new ValidationResult("InviteCode already exists", new List <string> {
                    nameof(inviteCode.Code)
                }));
            }
            return(ValidationResult.Success);
        }
        public async Task <IHttpActionResult> PostInvite(string inviteEmail)
        {
            var user = db.Users.Find(User.Identity.GetUserId());
            var code = new InviteCode();

            var inviteExists = db.Invitations.Any(i => i.InvitedEmail == inviteEmail);

            var invite = new Invitation();

            if (inviteExists)
            {
                invite = db.Invitations.Where(i => i.InvitedEmail == inviteEmail).FirstOrDefault();
            }

            else
            {
                invite = new Invitation()
                {
                    Code         = code.MakeCode(),
                    HouseHoldId  = user.HouseHoldId,
                    InvitedEmail = inviteEmail
                };

                db.Invitations.Add(invite);
            }

            var invitedUserExists = db.Users.Any(u => u.Email == inviteEmail);

            //var url = invitedUserExists ? Url.Link("JoinHouseHoldEU", "") : Url.Link("JoinHouseHoldNU", "");

            var mailer  = new EmailService();
            var message = new IdentityMessage()
            {
                Subject     = "New Invitation from rgoodwin-budget.azurewebsites.net",
                Destination = inviteEmail,
                Body        = "You have been invited to join " + user.UserName + "'s HouseHold. To join please follow this <a href=\'" + "\'>link </a> and use this code: " + invite.Code
            };

            await db.SaveChangesAsync();

            await mailer.SendAsync(message);

            return(Ok(invite));
        }
示例#16
0
 public override int GetHashCode()
 {
     unchecked {
         const int randomPrime = 397;
         int       hashCode    = Id.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Email != null ? Email.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Password != null ? Password.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ CreatedAt.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (EmailConfirmedAt != null ? EmailConfirmedAt.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (DeletedAt != null ? DeletedAt.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (InviteCode != null ? InviteCode.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (UniversityId != null ? UniversityId.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Role != null ? Role.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (AcademicField != null ? AcademicField.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (AcademicResume != null ? AcademicResume.GetHashCode() : 0);
         return(hashCode);
     }
 }
示例#17
0
        /// <summary>
        /// Создает код приглашения указывающий
        /// на нового пользователя из <paramref name="model" />
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static InviteCode CreateInviteCode(SendInviteModel model)
        {
            User user = new User()
            {
                UserName     = model.Email,
                UserInfo     = new UserInfo(),
                AccessRoleId = model.RoleId
            };

            StatusService.ChangeStatus(user, UserStatusType.Invite, null, "Invite created");

            InviteCode invite = new InviteCode()
            {
                User     = user,
                Code     = PasswordService.GeneratePasswordString(30),
                ActiveTo = DateTime.Now.AddDays(Properties.Settings.Default.DaysForInviteToLive)
            };

            return(invite);
        }
示例#18
0
        public IActionResult CreateInviteCode(string username)
        {
            InviteCode inviteCode = new InviteCode();

            inviteCode.Active = true;
            inviteCode.Code   = Guid.NewGuid().ToString();

            if (!string.IsNullOrEmpty(username))
            {
                if (!UserHelper.UserExists(_dbContext, username))
                {
                    return(new StatusCodeResult(StatusCodes.Status404NotFound));
                }
                User user = UserHelper.GetUser(_dbContext, username);
                inviteCode.Owner = user;
            }
            _dbContext.InviteCodes.Add(inviteCode);
            _dbContext.SaveChanges();

            return(Json(new { result = new { code = inviteCode.Code } }));
        }
示例#19
0
        /// <summary>
        /// Посылает приглашение на регистрацию указанному пользователю
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ServiceResponce SendInvite(SendInviteModel model)
        {
            if (UserRep.CountByCredentails(model.Email, null) != 0)
            {
                return(ServiceResponce
                       .FromFailed()
                       .Add("error", "User with Email " + model.Email + " already exist in system"));
            }
            InviteCode Invite = SendInviteModelHelper.CreateInviteCode(model);

            if (InviteRep.Add(Invite))
            {
                // Создаем задачу отправки сообщения в фоне и запускаем ее
                new Thread(send =>
                {
                    InviteEmailModel InviteEmailModel = InviteEmailModelHelper.GetInviteEmailModel(Invite);
                    string inviteText = TemplateServ
                                        .Run("Emails/Invite", typeof(InviteEmailModel), InviteEmailModel);
                    if (!EmailService.SendMail(InviteEmailModel, inviteText))
                    {
                        StatusService.ChangeStatus(Invite.User, UserStatusType.Invite, null, "Invite Email was not delivered");
                    }
                    else
                    {
                        StatusService.ChangeStatus(Invite.User, UserStatusType.Invite, null, "Invite Email was delivered");
                    }
                    InviteRep.Update(Invite);
                }).Start();

                return(ServiceResponce
                       .FromSuccess()
                       .Result("invite for user sended"));
            }
            else
            {
                return(ServiceResponce
                       .FromFailed()
                       .Add("error", "error saving invited user in DB"));
            }
        }
示例#20
0
        /// <summary>
        /// 推荐码
        /// </summary>
        /// <returns></returns>
        public ActionResult IntroducerCode()
        {
            ViewData["user"] = C_UserVM.GetVMByID(CurrentUser.ID);
            InviteCode code = WeModels.InviteCode.GetListByUserName(CurrentUser.UserName, "推荐");

            if (code == null || code.ValidDat < DateTime.Now)
            {
                code          = new InviteCode();
                code.UserName = CurrentUser.UserName;
                code.ValidDat = DateTime.Now.AddMinutes(20);//二十分钟有效
                code.Type     = "推荐";
                code.ID       = code.InsertAndReturnIdentity();
            }
            ViewData["code"] = code;

            List <C_UserType> userTypes = C_UserType.GetC_UserTypeHeighter(CurrentUser.ID).ToList();

            userTypes             = userTypes.OrderByDescending(m => m.Lever).ToList();
            ViewData["userTypes"] = userTypes;

            return(View());
        }
示例#21
0
        /// <summary>
        /// Проверяет есть ли активный, непринятый инвайт по коду,
        /// Если есть: возвращает Email приглашенного пользователя для использования при обновлении информации;
        /// Если он есть но просрочен: удаляет приглашенного пользователя и инвайт для него;
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public ServiceResponce CheckInviteExist(string code)
        {
            InviteCode invite = InviteRep.FindOneByCode(code);

            if (invite == null)
            {
                return(ServiceResponce
                       .FromFailed()
                       .Add("error", "Invite for this code do not exist"));
            }
            if (invite.ActiveTo < DateTime.Now)
            {
                this.DeleteInviteAndUser(invite);

                return(ServiceResponce
                       .FromFailed()
                       .Add("error", "Invite is out of date and will be removed"));
            }
            return(ServiceResponce
                   .FromSuccess()
                   .Result("Founded")
                   .Add("Email", invite.User.UserName));
        }
示例#22
0
        public async Task <ActionResult <InviteCodeApiDto> > PostInviteCode()
        {
            var currentUser = await _userManager.GetUserAsync(User);

            var issuedCount = await _context.InviteCodes
                              .CountAsync(ic => ic.IssuedById == currentUser.Id);

            if (issuedCount >= _config.MaxInvitesPerUser)
            {
                return(Unauthorized($"You cannot generate more than {_config.MaxInvitesPerUser} codes"));
            }

            var code = new InviteCode
            {
                Code     = GenerateCode(),
                IssuedBy = currentUser
            };
            await _context.InviteCodes.AddAsync(code);

            await _context.SaveChangesAsync();

            return(_mapper.Map <InviteCode, InviteCodeApiDto>(code));
        }
示例#23
0
        public static User CreateUser(TeknikEntities db, Config config, string username, string inviteCode)
        {
            try
            {
                User newUser = new User();
                newUser.Username       = username;
                newUser.UserSettings   = new UserSettings();
                newUser.BlogSettings   = new BlogSettings();
                newUser.UploadSettings = new UploadSettings();

                // if they provided an invite code, let's assign them to it
                if (!string.IsNullOrEmpty(inviteCode))
                {
                    InviteCode code = db.InviteCodes.Where(c => c.Code == inviteCode).FirstOrDefault();
                    db.Entry(code).State = EntityState.Modified;

                    newUser.ClaimedInviteCode = code;
                }

                // Add User
                db.Users.Add(newUser);

                // Generate blog for the user
                var newBlog = new Blog.Models.Blog();
                newBlog.User = newUser;
                db.Blogs.Add(newBlog);

                // Save the changes
                db.SaveChanges();

                return(newUser);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to create user.", ex);
            }
        }
        public async Task <ActionResult <InviteCodeDto> > CreateInviteCode()
        {
            var user = await _userManger.GetUserAsync(User);

            if (user == null)
            {
                return(BadRequest("User not found"));
            }

            var group = await _uow.Groups.GetGroupForUserAsync(user.Id);

            if (group == null)
            {
                return(BadRequest("User not in Group"));
            }

            var inviteCode = new InviteCode
            {
                //TODO generate as often until unique
                Code         = GenerateInviteCode(),
                CreationDate = DateTime.Now
            };

            group.InviteCodes.Add(inviteCode);

            try
            {
                await _uow.SaveChangesAsync();
            }
            catch (ValidationException ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(new InviteCodeDto(inviteCode)));
        }
示例#25
0
        /// <summary>
        /// Обновляет данные приглашения пользователя
        /// и переводит статус приглашения в статус ожидающий
        /// "Акцепта(ТЗ стр.8)"
        /// </summary>
        /// <param name="code">Код приглашения</param>
        /// <param name="model">Модель с данными для обновления</param>
        /// <returns></returns>
        public ServiceResponce UpdateInvite(string code, UpdateInviteModel model)
        {
            InviteCode invite = InviteRep.FindOneByCode(code);

            if (invite == null)
            {
                return(ServiceResponce
                       .FromFailed()
                       .Add("error", "invite not found"));
            }

            User user = UserRep.FindOneById(invite.User.Id);

            if (!StatusService.CanChangeStatus(user, UserStatusType.AcceptInvite))
            {
                return(ServiceResponce
                       .FromFailed()
                       .Add("error", "it isn't possible to change the status to AcceptInvited"));
            }


            if (!UserService.CanUpdateUserCredentails(user.Id, model.Email, model.Phone, UserRep))
            {
                return(ServiceResponce
                       .FromFailed()
                       .Add("error", "user with such Email or Phone already exists"));
            }

            if (!model.GeneratePassword && !PasswordService.IsPasswordAcceptable(model.Password))
            {
                return(ServiceResponce
                       .FromFailed()
                       .Add("error", "Password not acceptable"));
            }

            // Генерируем и хэшируем пароль
            string Password = model.Password;

            if (model.GeneratePassword)
            {
                Password = PasswordService.GeneratePasswordString();
            }
            model.Password = PasswordService.GeneratePasswordHash(Password);

            user = UpdateInviteModelHelper.UpdateInviteUser(user, model);



            UserRep.Save(user);
            InviteRep.Delete(invite.Id);

            ServiceResponce response = ServiceResponce
                                       .FromSuccess()
                                       .Result("invite accepted");

            if (model.GeneratePassword)
            {
                response.Add("GeneratedPassword", Password);
            }
            return(response);
        }
        public async Task<IHttpActionResult> PostInvite(string inviteEmail)
        {
            var user = db.Users.Find(User.Identity.GetUserId());
            var code = new InviteCode();

            var inviteExists = db.Invitations.Any(i => i.InvitedEmail == inviteEmail);
            
            var invite = new Invitation();
            
            if (inviteExists)
            {
                invite = db.Invitations.Where(i=> i.InvitedEmail == inviteEmail).FirstOrDefault();
            }
            
            else 
            {
                invite = new Invitation() 
                {
                    Code = code.MakeCode(),
                    HouseHoldId = user.HouseHoldId,
                    InvitedEmail = inviteEmail
                };

                db.Invitations.Add(invite);

            }
            
            var invitedUserExists = db.Users.Any(u=> u.Email == inviteEmail);

            //var url = invitedUserExists ? Url.Link("JoinHouseHoldEU", "") : Url.Link("JoinHouseHoldNU", "");
            
            var mailer = new EmailService();
            var message = new IdentityMessage() 
            {
                Subject = "New Invitation from rgoodwin-budget.azurewebsites.net",
                Destination = inviteEmail,
                Body = "You have been invited to join " + user.UserName + "'s HouseHold. To join please follow this <a href=\'" + "\'>link </a> and use this code: " + invite.Code
            };

            await db.SaveChangesAsync();
            await mailer.SendAsync(message);

            return Ok(invite);

        }
示例#27
0
        public ActionResult SignUp(User user, string inviteCode)
        {
            if (user != null)
            {
                if (ModelState.IsValid)
                {
                    // Generate salt and salted/hashed password for db storage
                    string salt           = StringManipulator.GenerateSalt();
                    string hashedPassword = StringManipulator.GenerateHashedPassword(salt, user.Password);

                    // Set user properties
                    user.Password   = hashedPassword;
                    user.Salt       = salt;
                    user.Role       = "Standard";
                    user.Position   = "N/A";
                    user.EmployeeID = user.FirstName[0] + user.LastName[0] + StringManipulator.GenerateIdNumber(8);
                    user.RegDate    = DateTime.Now;

                    // If an invite code was present, join that org. If not, create a new one
                    if (string.IsNullOrEmpty(inviteCode))
                    {
                        Organization org = new Organization();

                        // Set Organization properties
                        org.Label          = user.Organization.Label;
                        org.Registered     = DateTime.Now;
                        org.CodesCount     = 1;
                        org.OrganizationID = org.Label + "#" + StringManipulator.GenerateIdNumber(8);

                        // Add new org to database
                        db.Organizations.Add(org);
                        db.SaveChanges();

                        // Link the user to the newly created org
                        user.Organization   = org;
                        user.OrganizationID = org.Id;
                    }
                    else
                    {
                        // Find the organization relating to the invite code
                        InviteCode code = db.InviteCodes.FirstOrDefault(i => i.Code == inviteCode);

                        // If the code is valid,
                        if (code != null && !code.IsExpired)
                        {
                            user.OrganizationID = code.OrganizationID;

                            code.IsExpired   = true;
                            code.DateExpired = DateTime.Now;

                            // Commit invite code changes
                            db.SaveChanges();
                        }
                    }

                    // Commit user changes
                    db.Users.Add(user);
                    db.SaveChanges();

                    // Log the user creation event
                    EventLogger.LogNewEvent(user.Id, user.OrganizationID, LoggingEventType.UserCreated, "");
                }
            }

            return(View("Login"));
        }
示例#28
0
        public void Invoke(string[] args)
        {
            var options = new OptionSet();

            options.Add(
                "?|help",
                "Show help information.",
                x => HelpUtility.WriteHelpInformation(this, options)
                );

            List <string> parsedArgs = null;

            if (args != null)
            {
                try
                {
                    parsedArgs = options.Parse(args);
                }
                catch (OptionException ex)
                {
                    CommandResult.WriteLine(ex.Message);
                }
            }

            var registrationStatus = _dataBucket.VariableRepository.GetVariable("Registration");

            if (registrationStatus.Equals("Open", StringComparison.InvariantCultureIgnoreCase) || CommandResult.CommandContext.PromptData != null)
            {
                CommandResult.CommandContext.Prompt = false;
                InviteCode inviteCode = null;
                if (CommandResult.CommandContext.PromptData != null)
                {
                    inviteCode = _dataBucket.InviteCodeRepository.GetInviteCode(CommandResult.CommandContext.PromptData[0]);
                }

                if (CommandResult.CommandContext.PromptData == null || inviteCode != null)
                {
                    if (inviteCode != null)
                    {
                        if (parsedArgs == null)
                        {
                            parsedArgs = new List <string> {
                                inviteCode.Username
                            }
                        }
                        ;
                        else
                        {
                            parsedArgs.Insert(0, inviteCode.Username);
                        }
                    }
                    if ((parsedArgs == null || parsedArgs.Count == 0))
                    {
                        CommandResult.WriteLine("Enter your desired username. (no spaces. sorry.)");
                        CommandResult.SetContext(ContextStatus.Forced, Name, args, "Username");
                    }
                    else if (parsedArgs.Count == 1)
                    {
                        if (parsedArgs[0].Length >= 3 && parsedArgs[0].Length <= 30)
                        {
                            if (!_dataBucket.UserRepository.CheckUserExists(parsedArgs[0]))
                            {
                                CommandResult.WriteLine("Enter your desired password.");
                                CommandResult.PasswordField = true;
                                CommandResult.SetContext(ContextStatus.Forced, Name, args, "Password");
                            }
                            else
                            {
                                CommandResult.WriteLine("Username already exists.");
                                CommandResult.WriteLine("Enter a different username.");
                                CommandResult.SetContext(ContextStatus.Forced, Name, null, "Username");
                            }
                        }
                        else
                        {
                            CommandResult.WriteLine("Username must be between 3 and 15 characters.");
                            CommandResult.WriteLine("Enter a different username.");
                            CommandResult.SetContext(ContextStatus.Forced, Name, null, "Username");
                        }
                    }
                    else if (parsedArgs.Count == 2)
                    {
                        if (parsedArgs[0].Length >= 3 && parsedArgs[0].Length <= 15)
                        {
                            if (!_dataBucket.UserRepository.CheckUserExists(parsedArgs[0]))
                            {
                                CommandResult.WriteLine("Re-enter your desired password.");
                                CommandResult.PasswordField = true;
                                CommandResult.SetContext(ContextStatus.Forced, Name, args, "Confirm Password");
                            }
                            else
                            {
                                CommandResult.WriteLine("Username already exists.");
                                CommandResult.WriteLine("Enter your desired username.");
                                CommandResult.SetContext(ContextStatus.Forced, Name, null, "Username");
                            }
                        }
                        else
                        {
                            CommandResult.WriteLine("Username must be between 3 and 15 characters.");
                            CommandResult.WriteLine("Enter a different username.");
                            CommandResult.SetContext(ContextStatus.Forced, Name, null, "Username");
                        }
                    }
                    else if (parsedArgs.Count == 3)
                    {
                        if (parsedArgs[0].Length >= 3 && parsedArgs[0].Length <= 15)
                        {
                            var user = _dataBucket.UserRepository.GetUser(parsedArgs[0]);
                            if (user == null)
                            {
                                if (parsedArgs[1] == parsedArgs[2])
                                {
                                    user = new User
                                    {
                                        Username  = parsedArgs[0],
                                        Password  = parsedArgs[1],
                                        JoinDate  = DateTime.UtcNow,
                                        LastLogin = DateTime.UtcNow,
                                        TimeZone  = "UTC",
                                        Sound     = true,
                                    };
                                    var role = _dataBucket.UserRepository.GetRole("User");
                                    user.Roles = new List <Role> {
                                        role
                                    };

                                    if (inviteCode != null)
                                    {
                                        _dataBucket.InviteCodeRepository.DeleteInviteCode(inviteCode);
                                    }

                                    _dataBucket.UserRepository.AddUser(user);
                                    _dataBucket.SaveChanges();


                                    var defaultAliases = new List <Alias>
                                    {
                                        new Alias
                                        {
                                            Username = user.Username,
                                            Shortcut = "lb",
                                            Command  = "BOARDS"
                                        },
                                        new Alias
                                        {
                                            Username = user.Username,
                                            Shortcut = "b",
                                            Command  = "BOARD"
                                        },
                                        new Alias
                                        {
                                            Username = user.Username,
                                            Shortcut = "t",
                                            Command  = "TOPIC"
                                        },
                                        new Alias
                                        {
                                            Username = user.Username,
                                            Shortcut = "lm",
                                            Command  = "MESSAGES"
                                        },
                                        new Alias
                                        {
                                            Username = user.Username,
                                            Shortcut = "m",
                                            Command  = "MESSAGE"
                                        }
                                    };

                                    defaultAliases.ForEach(x => _dataBucket.AliasRepository.AddAlias(x));
                                    _dataBucket.SaveChanges();

                                    CommandResult.CurrentUser = user;
                                    CommandResult.WriteLine("Thank you for registering.");
                                    //CommandResult.WriteLine();
                                    //var STATS = AvailableCommands.SingleOrDefault(x => x.Name.Is("STATS"));
                                    //STATS.Invoke(new string[] { "-users" });
                                    CommandResult.WriteLine();
                                    CommandResult.WriteLine("You are now logged in as {0}.", CommandResult.CurrentUser.Username);
                                    CommandResult.DeactivateContext();
                                }
                                else
                                {
                                    CommandResult.WriteLine("Passwords did not match.");
                                    CommandResult.WriteLine("Enter your desired password.");
                                    CommandResult.PasswordField = true;
                                    CommandResult.SetContext(ContextStatus.Forced, Name, new string[] { parsedArgs[0] }, "Password");
                                }
                            }
                            else
                            {
                                CommandResult.WriteLine("Username already exists.");
                                CommandResult.WriteLine("Enter your desired username.");
                                CommandResult.SetContext(ContextStatus.Forced, Name, null, "Username");
                            }
                        }
                        else
                        {
                            CommandResult.WriteLine("Username must be between 3 and 15 characters.");
                            CommandResult.WriteLine("Enter a different username.");
                            CommandResult.SetContext(ContextStatus.Forced, Name, null, "Username");
                        }
                    }
                }
                else
                {
                    CommandResult.WriteLine("You did not supply a valid invite code.");
                    CommandResult.DeactivateContext();
                }
            }
            else if (registrationStatus.Equals("Invite-Only", StringComparison.InvariantCultureIgnoreCase))
            {
                CommandResult.WriteLine("Enter your invite code.");
                CommandResult.SetPrompt(Name, args, "Invite Code");
            }
            else if (registrationStatus.Equals("Closed", StringComparison.InvariantCultureIgnoreCase))
            {
                CommandResult.WriteLine("Registration is currently closed.");
            }
        }
示例#29
0
 public void AddInviteCode(InviteCode inviteCode)
 {
     _entityContainer.InviteCodes.Add(inviteCode);
 }
示例#30
0
 public void DeleteInviteCode(InviteCode inviteCode)
 {
     _entityContainer.InviteCodes.Remove(inviteCode);
 }
        public async Task<IHttpActionResult> PostInvite(WebApiSucksSoMuch inviteEmail)
        {
            if (inviteEmail.Email == "")
            {
                string error = "noEmail";
                return Ok(error);
            }

            var user = db.Users.Find(User.Identity.GetUserId());

            InviteCode code = new InviteCode();

            var invite = db.Invitation.FirstOrDefault(i => i.InvitedEmail == inviteEmail.Email && i.HouseholdId == user.HouseholdId);

            if(invite == null)
            {
                invite = new Invitaton()
                {
                    Code = code.CreateCode(),
                    HouseholdId = user.HouseholdId,
                    InvitedEmail = inviteEmail.Email
                };

                db.Invitation.Add(invite);
            }

            var invitedUserExists = db.Users.Any(u => u.Email == inviteEmail.Email);

            //var url = invitedUserExists ? Url.Route("Go to join view", "") : Url.Route("Go to register and join view", "");

            var mailer = new EmailService();

            var message = new IdentityMessage()
            {
                Subject = "You've been invited",
                Destination = inviteEmail.Email,
                Body = "You've been invited to join " + user.DisplayName + "'s household. This is your join code: " +  invite.Code
            };

            await db.SaveChangesAsync();

            await mailer.SendAsync(message);

            return Ok(invite);

        }
示例#32
0
        public bool Login()
        {
            string OAuthVerifier      = string.Empty;
            string OAuthenticityToken = string.Empty;
            string OAuthToken         = string.Empty;
            string PinToken           = string.Empty;
            string InviteUrl          = string.Empty;

            bool IsAccountCreated = false;

            try
            {
                string ts = GenerateTimeStamp();

                InviteUrl = "http://pinterest.com/invited/?email=" + PinEmail + "&invite=" + InviteCode;
                InviteUrl = "http://pinterest.com/invited/?invite=" + InviteCode;

                int intProxyPort = 80;
                if (ApplicationData.ValidateNumber(this.proxyPort))
                {
                    intProxyPort = int.Parse(this.proxyPort);
                }

                string TwitterPageContent = httpHelper.getHtmlfromUrlProxy(new Uri("https://twitter.com/"), "", this.proxyAddress, intProxyPort, this.proxyUsername, this.proxyPassword, this.userAgent);
                string BootPageContent    = httpHelper.getHtmlfromUrl(new Uri("https://twitter.com/account/bootstrap_data?r=0.9414130715097342"), "https://twitter.com/", "", this.userAgent);

                //string PostData = "session%5Busername_or_email%5D=" + TwitterUsername + "&session%5Bpassword%5D=" + TwitterPassword  + "&scribe_log=%5B%22%7B%5C%22event_name%5C%22%3A%5C%22web%3Afront%3Alogin_callout%3Aform%3A%3Alogin_click%5C%22%2C%5C%22noob_level%5C%22%3Anull%2C%5C%22internal_referer%5C%22%3Anull%2C%5C%22user_id%5C%22%3A0%2C%5C%22page%5C%22%3A%5C%22front%5C%22%2C%5C%22_category_%5C%22%3A%5C%22client_event%5C%22%2C%5C%22ts%5C%22%3A" + ts + "%7D%22%5D&redirect_after_login="******"https://twitter.com/sessions?phx=1"), PostData, "https://twitter.com/", "" , this.userAgent);

                //string ts = GenerateTimeStamp();
                string get_twitter_first = string.Empty;
                try
                {
                    get_twitter_first = httpHelper.getHtmlfromUrlProxy(new Uri("https://twitter.com/"), "", proxyAddress, 0, proxyUsername, proxyPassword, "");
                }
                catch (Exception ex)
                {
                    //string get_twitter_first = globusHttpHelper1.getHtmlfromUrlp(new Uri("http://twitter.com/"), string.Empty, string.Empty);
                    //Thread.Sleep(1000);
                    get_twitter_first = httpHelper.getHtmlfromUrlProxy(new Uri("https://twitter.com/"), "", proxyAddress, 0, proxyUsername, proxyPassword, "");
                }

                string postAuthenticityToken = "";

                int startIndx = get_twitter_first.IndexOf("postAuthenticityToken");
                if (startIndx > 0)
                {
                    int indexstart = startIndx + "postAuthenticityToken".Length + 3;
                    int endIndx    = get_twitter_first.IndexOf("\"", startIndx);

                    postAuthenticityToken = get_twitter_first.Substring(startIndx, endIndx - startIndx).Replace(",", "");

                    if (postAuthenticityToken.Contains("postAuthenticityToken"))
                    {
                        try
                        {
                            string[] getOuthentication = System.Text.RegularExpressions.Regex.Split(get_twitter_first, "\"postAuthenticityToken\":\"");
                            string[] authenticity      = System.Text.RegularExpressions.Regex.Split(getOuthentication[1], ",");

                            if (authenticity[0].IndexOf("\"") > 0)
                            {
                                int    indexStart1 = authenticity[0].IndexOf("\"");
                                string start       = authenticity[0].Substring(0, indexStart1);
                                postAuthenticityToken = start.Replace("\"", "").Replace(":", "");
                            }
                        }
                        catch { };
                    }
                }
                else
                {
                    string[] array = System.Text.RegularExpressions.Regex.Split(get_twitter_first, "<input type=\"hidden\"");
                    foreach (string item in array)
                    {
                        if (item.Contains("authenticity_token"))
                        {
                            int startindex = item.IndexOf("value=\"");
                            if (startindex > 0)
                            {
                                string start    = item.Substring(startindex).Replace("value=\"", "");
                                int    endIndex = start.IndexOf("\"");
                                string end      = start.Substring(0, endIndex);
                                postAuthenticityToken = end;
                                break;
                            }
                        }
                    }
                }

                string get_twitter_second = httpHelper.postFormData(new Uri("https://twitter.com/scribe"), "log%5B%5D=%7B%22event_name%22%3A%22web%3Amobile_gallery%3Agallery%3A%3A%3Aimpression%22%2C%22noob_level%22%3Anull%2C%22internal_referer%22%3Anull%2C%22context%22%3A%22mobile_gallery%22%2C%22event_info%22%3A%22mobile_app_download%22%2C%22user_id%22%3A0%2C%22page%22%3A%22mobile_gallery%22%2C%22_category_%22%3A%22client_event%22%2C%22ts%22%3A" + ts + "%7D", "https://twitter.com/?lang=en&logged_out=1#!/download", "", ""); //globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/account/bootstrap_data?r=0.21632839148912897"), "https://twitter.com/", string.Empty);

                string get2nd = httpHelper.getHtmlfromUrlProxy(new Uri("http://twitter.com/account/bootstrap_data?r=0.21632839148912897"), "https://twitter.com/", proxyAddress, 0, proxyUsername, proxyPassword, "");

                string get_api = httpHelper.getHtmlfromUrl(new Uri("http://api.twitter.com/receiver.html"), "https://twitter.com/", "", "");


                //Old postdata
                //string postData = "session%5Busername_or_email%5D=" + Username + "&session%5Bpassword%5D=" + Password + "&scribe_log=%5B%22%7B%5C%22event_name%5C%22%3A%5C%22web%3Afront%3Alogin_callout%3Aform%3A%3Alogin_click%5C%22%2C%5C%22noob_level%5C%22%3Anull%2C%5C%22internal_referer%5C%22%3Anull%2C%5C%22user_id%5C%22%3A0%2C%5C%22page%5C%22%3A%5C%22front%5C%22%2C%5C%22_category_%5C%22%3A%5C%22client_event%5C%22%2C%5C%22ts%5C%22%3A" + ts + "%7D%22%5D&redirect_after_login="******"session%5Busername_or_email%5D=" + TwitterUsername + "&session%5Bpassword%5D=" + TwitterPassword + "&scribe_log=&redirect_after_login=&authenticity_token=" + postAuthenticityToken + "";

                string response_Login = httpHelper.postFormData(new Uri("https://twitter.com/sessions"), postData, "https://twitter.com/", "", "");


                string AfterPostPageContent = httpHelper.getHtmlfromUrl(new Uri("https://twitter.com/"), "https://twitter.com/", "", this.userAgent);

                if (AfterPostPageContent.Contains("signout-button"))
                {
                    string InvitePageContent = httpHelper.getHtmlfromUrl(new Uri(InviteUrl), "", "", this.userAgent);

                    if (InvitePageContent.Contains("This invite code is not valid"))
                    {
                        IsAccountCreated = false;
                        Log("[ " + DateTime.Now + " ] => [ This invite code is not valid " + PinEmail + " ]");
                        return(IsAccountCreated);
                    }

                    string InvitedPageContent = httpHelper.getHtmlfromUrl(new Uri("http://pinterest.com/twitter/?invited=1"), InviteUrl, "", this.userAgent);

                    if (InvitedPageContent.Contains("Logout"))
                    {
                        IsAccountCreated = true;
                        Log("[ " + DateTime.Now + " ] => [ This twitter account allready added with pinterest " + TwitterUsername + " ]");
                        return(IsAccountCreated);
                    }

                    Uri ResponseUri = httpHelper.GetResponseData();


                    if (!string.IsNullOrEmpty(ResponseUri.OriginalString))
                    {
                        if (ResponseUri.OriginalString.Contains("verify_captcha/?"))
                        {
                            //List<string> lstData = GetCapctha();
                            //string challenge = string.Empty;
                            //string response = string.Empty;


                            //challenge = lstData[0].ToString();
                            //response = lstData[1].ToString();
                            //response = response.Replace(" ", "+");
                            //string postUrl = "http://pinterest.com/verify_captcha/?src=register&return=%2Fwelcome%2F";
                            //string postData = "challenge=" + challenge + "&response=" + response;

                            //string POstResponse = httpHelper.postFormData(new Uri(postUrl), postData, "", string.Empty);

                            //string pageSrcWelcome = httpHelper.getHtmlfromUrl(new Uri("http://pinterest.com/welcome/"), postUrl, "");
                        }
                        if (ResponseUri.OriginalString.Contains("http://pinterest.com/twitter/?oauth_token"))
                        {
                            OAuthVerifier = ResponseUri.OriginalString;

                            int    FirstPointToken     = InvitedPageContent.IndexOf("csrfmiddlewaretoken");
                            string FirstTokenSubString = InvitedPageContent.Substring(FirstPointToken);

                            int SecondPointToken = FirstTokenSubString.IndexOf("/>");
                            PinToken = FirstTokenSubString.Substring(0, SecondPointToken).Replace("csrfmiddlewaretoken", string.Empty).Replace("value=", string.Empty).Replace("'", string.Empty).Trim();
                        }
                        if (ResponseUri.OriginalString.Contains("api.twitter.com/oauth/authenticate?oauth_token="))
                        {
                            int FirstAuthenticityPoint = InvitedPageContent.IndexOf("authenticity_token\" type=\"hidden\"");

                            string FirstSubAuthenticity = InvitedPageContent.Substring(FirstAuthenticityPoint);
                            OAuthenticityToken = FirstSubAuthenticity.Substring(FirstSubAuthenticity.IndexOf("value="), (FirstSubAuthenticity.IndexOf("/></div>")) - (FirstSubAuthenticity.IndexOf("value="))).Replace("value=", string.Empty).Replace("\"", string.Empty).Trim();

                            OAuthToken = ResponseUri.OriginalString.Replace("https://api.twitter.com/oauth/authenticate?oauth_token=", string.Empty).Replace("http://api.twitter.com/oauth/authenticate?oauth_token=", string.Empty);

                            string AcceptPostData = "authenticity_token=" + OAuthenticityToken + "&oauth_token=" + OAuthToken;

                            string OauthUrl = "https://twitter.com/oauth/authenticate?oauth_token=" + OAuthToken;

                            string AcceptedPageContent = httpHelper.postFormData(new Uri("https://twitter.com/oauth/authenticate"), AcceptPostData, OauthUrl, string.Empty, this.userAgent);

                            int FirstOAuthVerifierPoint = AcceptedPageContent.IndexOf("http://pinterest.com/twitter/?oauth_token=");

                            string FirstSuboAuth = AcceptedPageContent.Substring(FirstOAuthVerifierPoint);

                            OAuthVerifier = FirstSuboAuth.Substring(0, FirstSuboAuth.IndexOf(">")).Replace("\"", string.Empty).Trim();//.Replace("&oauth_verifier=", string.Empty).Trim();

                            string PinterestRegistrationPageContent = httpHelper.getHtmlfromUrl(new Uri(OAuthVerifier), string.Empty, string.Empty, this.userAgent);

                            if (!PinterestRegistrationPageContent.Contains("Oops! We are having some issues talking to Twitter. Please try again later"))
                            {
                                int    FirstPointToken     = PinterestRegistrationPageContent.IndexOf("csrfmiddlewaretoken");
                                string FirstTokenSubString = PinterestRegistrationPageContent.Substring(FirstPointToken);

                                int SecondPointToken = FirstTokenSubString.IndexOf("/>");
                                PinToken = FirstTokenSubString.Substring(0, SecondPointToken).Replace("csrfmiddlewaretoken", string.Empty).Replace("value=", string.Empty).Replace("'", string.Empty).Trim();
                            }
                            else
                            {
                                Log("[ " + DateTime.Now + " ] => [ We are having some issues talking to Twitter. Please try again later ]");
                                return(false);
                            }
                        }


                        //Checking For User Name
                        string CheckUserNameUrl = "http://pinterest.com/check_username/?check_username="******"&csrfmiddlewaretoken=" + PinToken;
                        string User             = httpHelper.getHtmlfromUrl(new Uri(CheckUserNameUrl), OAuthVerifier, PinToken, this.userAgent);

                        if (User.Contains("username is already"))
                        {
                            int num = RandomNumberGenerator.GenerateRandom(100, 1000);

                            PinUserName = PinUserName + num.ToString();

                            //Checking For User Name
                            CheckUserNameUrl = "http://pinterest.com/check_username/?check_username="******"&csrfmiddlewaretoken=" + PinToken;
                            User             = httpHelper.getHtmlfromUrl(new Uri(CheckUserNameUrl), OAuthVerifier, PinToken, this.userAgent);
                        }

                        ////Checking For User Name
                        //string CheckEmailUrl = "http://pinterest.com/check_username/?check_email=" + PinEmail + "&csrfmiddlewaretoken=" + PinToken;
                        //string Email = httpHelper.getHtmlfromUrl(new Uri(CheckEmailUrl), OAuthVerifier, PinToken);

                        //if (!Email.Contains("success"))
                        //{
                        //    //IsPinLoggedIn = true;
                        //    Log("This email not valid " + PinEmail);
                        //    return;
                        //}
                        string RegistrationPostData = "username="******"&email=" + PinEmail + "&password="******"&invite=" + InviteCode.Replace(" ", "").Replace("http://email.pinterest.com/wf/click&upn=", "") + "&twitter=1&csrfmiddlewaretoken=" + PinToken + "&user_image=http%3A%2F%2Fimg.tweetimag.es%2Fi%2FSocioPro_o";

                        string RegistredPageContent = httpHelper.postFormData(new Uri("http://pinterest.com/register/"), RegistrationPostData, OAuthVerifier, string.Empty, this.userAgent);

                        if (RegistredPageContent.Contains("recaptcha/api/js/recaptcha"))
                        {
                            List <string> lstData   = GetCapctha();
                            string        challenge = string.Empty;
                            string        response  = string.Empty;


                            challenge = lstData[0].ToString();
                            response  = lstData[1].ToString();
                            response  = response.Replace(" ", "+");
                            string postUrl   = "http://pinterest.com/verify_captcha/?src=register&return=/welcome/";
                            string postData1 = "challenge=" + challenge + "&response=" + response;

                            string POstResponse = httpHelper.postFormData(new Uri(postUrl), postData1, OAuthVerifier, PinToken, this.userAgent);

                            RegistredPageContent = httpHelper.getHtmlfromUrl(new Uri("http://pinterest.com/welcome/"), "", "", this.userAgent);
                        }
                        if (RegistredPageContent.Contains("architecture"))
                        {
                            IsAccountCreated = true;
                            Log("[ " + DateTime.Now + " ] => [ Account Created " + PinUserName + " ]");
                        }
                        else
                        {
                            IsAccountCreated = false;
                            Log("[ " + DateTime.Now + " ] => [ Account Not Created " + PinUserName + " ]");
                            return(IsAccountCreated);
                        }

                        string WelcomPageContent = httpHelper.postFormData(new Uri("http://pinterest.com/welcome/"), "", OAuthVerifier, PinToken, this.userAgent);

                        //Changed By  Gargi On 22nd May 2012 --> request from fiddler changed
                        //string CategoryPostData = "categories=architecture&user_follow=true";

                        string CategoryPostData = "categories=art%2Ccars_motorcycles%2Cdesign%2Cdiy_crafts%2Ceducation%2Carchitecture%2Cfitness";

                        string CategoryPageContent = httpHelper.postFormData(new Uri("http://pinterest.com/welcome/"), CategoryPostData, "http://pinterest.com/welcome/", PinToken, this.userAgent);

                        if (CategoryPageContent.Contains("success"))
                        {
                            IsAccountCreated = true;
                            Log("[ " + DateTime.Now + " ] => [ Initial Category Added " + PinUserName + " ]");
                        }

                        string AllowUserPostData = "follow_users%5B%5D=sharp&follow_users%5B%5D=neillehepworth&follow_users%5B%5D=miamalm&follow_users%5B%5D=kiluka&follow_users%5B%5D=gaileguevara&follow_users%5B%5D=jellway&follow_users%5B%5D=richard_larue&follow_users%5B%5D=rayestudio&follow_users%5B%5D=jdraper&follow_users%5B%5D=shashashasha";
                        //if (string.IsNullOrEmpty(ApplicationData.UsersToFollow))
                        //{
                        //    AllowUserPostData = "follow_users%5B%5D=sharp&follow_users%5B%5D=neillehepworth&follow_users%5B%5D=miamalm&follow_users%5B%5D=kiluka&follow_users%5B%5D=gaileguevara&follow_users%5B%5D=jellway&follow_users%5B%5D=richard_larue&follow_users%5B%5D=rayestudio&follow_users%5B%5D=jdraper&follow_users%5B%5D=shashashasha";
                        //}
                        //else
                        //{
                        //    AllowUserPostData = ApplicationData.UsersToFollow;
                        //}

                        string AlloweduserPostData = httpHelper.postFormData(new Uri("http://pinterest.com/welcome/"), AllowUserPostData, "http://pinterest.com/welcome/", PinToken, this.userAgent);

                        if (AlloweduserPostData.Contains("success"))
                        {
                            IsAccountCreated = true;
                            Log("[ " + DateTime.Now + " ] => [ Intial User Added " + PinUserName + " ]");
                        }

                        string BordPostData = "board_names%5B%5D=Products+I+Love&board_names%5B%5D=Favorite+Places+%26+Spaces&board_names%5B%5D=Books+Worth+Reading&board_names%5B%5D=My+Style&board_names%5B%5D=For+the+Home";

                        string BoardPostedPageContent = httpHelper.postFormData(new Uri("http://pinterest.com/welcome/"), BordPostData, "http://pinterest.com/welcome/", PinToken, this.userAgent);

                        if (BoardPostedPageContent.Contains("success"))
                        {
                            IsAccountCreated = true;
                            Log("[ " + DateTime.Now + " ] => [ Intial Board Added " + PinUserName + " ]");
                        }
                    }

                    return(IsAccountCreated);
                }
                else
                {
                    Log("[ " + DateTime.Now + " ] => [ Twitter Account Not Logged In :" + TwitterUsername + " ]");
                    return(IsAccountCreated);
                }
            }
            catch (Exception ex)
            {
                //Log("Error " + ex.Message);
                return(IsAccountCreated);
            }
        }