Пример #1
0
        public static void Reg(Data.RegisUser regUser, Implementation.UsersRepository RepUsers)
        {
            regUser.Password = GetHash(regUser.Password);
            Data.User newUser = new Data.User();
            newUser.FirstName   = regUser.FirstName;
            newUser.LastName    = regUser.LastName;
            newUser.Email       = regUser.Email;
            newUser.PhoneNumber = regUser.PhoneNumber;
            newUser.Password    = regUser.Password;
            newUser.IsConfirm   = false;


            try
            {
                SendMail(new Data.LoginUser {
                    Email = regUser.Email, Password = regUser.Password
                },
                         WebConfigurationManager.AppSettings.GetValues("SubjectMailConfirm")[0],
                         WebConfigurationManager.AppSettings.GetValues("BodyMailConfirm")[0] + regUser.Password);

                RepUsers.Create(newUser);
                RepUsers.SaveChange();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Пример #2
0
        public static void Confirm(string id, Implementation.UsersRepository RepUsers)
        {
            var Users = RepUsers.GetAllWhere(u => u.IsConfirm == false && u.Password == id);

            if (Users != null)
            {
                foreach (Data.User item in Users)    // всех пользователей с этим хешем подтверждаем o_O ))))
                {
                    item.IsConfirm = true;
                }

                RepUsers.SaveChange();
            }
        }
Пример #3
0
        public static void GetNewPass(string email, Implementation.UsersRepository RepUsers, HttpContextBase MyHttpContext)
        {
            char[]        data = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
                                   'A',        'B', 'C', 'D', 'E', 'F', 'G',
                                   '0',        '1', '2', '3', '4', '5', '6','7','8', '9' };
            Random        rnd = new Random();
            StringBuilder SB  = new StringBuilder();

            for (int i = 0; i < 6; i++)
            {
                int index = rnd.Next(data.Count() - 1);
                SB.Append(data[index]);
            }

            string NewPass = SB.ToString();    //пароль
            string HPass   = GetHash(NewPass); // хеш пароля

            HttpCookie cookie = new HttpCookie("Test Site");

            cookie["email"] = email;

            MyHttpContext.Response.Cookies.Add(cookie);


            try
            {
                SendMail(new Data.LoginUser {
                    Email = email, Password = NewPass
                },
                         WebConfigurationManager.AppSettings.GetValues("SubjectMailNewPass")[0],
                         WebConfigurationManager.AppSettings.GetValues("BodyMailNewPass")[0] + NewPass);


                Data.User tmpUser = RepUsers.GetAllWhere(u => u.Email == email).First();
                tmpUser.Password = HPass;
                RepUsers.SaveChange();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }