Exemple #1
0
        public bool SaveUserInfo(string Email, int role, string FirstName, string LastName, string Country, string State, string Add1, string Add2, string serial, string Cellphone, string Phone1, string Phone2)
        {
            DAL.LoginModelDataContext createuser = new DAL.LoginModelDataContext();
            DAL.User user = new User();
            DAL.UsersDataContext userdata = new UsersDataContext();
            Helpers.Login_Security sec = new Helpers.Login_Security();
            Helpers.EmailSender sender = new Helpers.EmailSender();
            if (EmailExists(Email))
            {
                return false;
            }
            else
            {
                string salt = "TempSalt";
                string clearpass = sec.RandomString();
                string hashedpassword = sec.hashPass(salt, clearpass);
                user.Email = Email;
                user.FirstName = FirstName;
                user.LastName = LastName;
                user.Country = Country;
                user.State_Province = State;
                user.Address1 = Add1;
                user.Address2 = Add2;
                user.Salt = salt;
                user.RoleID = role;
                user.HashedPassword = hashedpassword;
                user.SerialNumber = serial;
                user.Cellphone = Cellphone;
                user.Phone1 = Phone1;
                user.Phone2 = Phone2;
                try
                {
                    createuser.Users.InsertOnSubmit(user);
                    createuser.SubmitChanges();
                    sender.UserCreate(Email, clearpass, serial);
                    return true;

                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
Exemple #2
0
        public bool CreateRandomPassword(string email)
        {
            try
            {
                DAL.LoginModelDataContext resetpsw = new DAL.LoginModelDataContext();
                Helpers.Login_Security sec = new Helpers.Login_Security();
                Helpers.EmailSender sender = new Helpers.EmailSender();
                List<string> UserInfo = new List<string>();
                if (EmailExists(email))
                {
                    return false;
                }
                else
                {
                    string salt = "TempSalt";
                    string clearpass = sec.RandomString();

                    string hashedpassword = sec.hashPass(salt, clearpass);

                    if (resetpsw.UpdatePassword(email, hashedpassword, salt))
                    {
                        sender.ResetPassword(email, clearpass);
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception)
            {
                return false;
            }
        }