예제 #1
0
        public static void login(string Email, string password)
        {
            MileStone4.AlmogException unicorn = new MileStone4.AlmogException();
            unicorn.Value = new List <String>(); // Collection of messages

            if (!(CheckPassword(password)))      // password cheack
            {
                ((List <String>)unicorn.Value).Add("Password isn't valid");
            }
            try
            {
                CheckEmailValid(Email);
            }
            catch (MileStone4.AlmogException e)
            {
                for (int i = 0; i < ((List <String>)e.Value).Count; i++) // add message
                {
                    ((List <String>)unicorn.Value).Add(((List <String>)e.Value)[i]);
                }
            }
            if (((List <String>)unicorn.Value).Count == 0 || (((List <String>)unicorn.Value).Count == 1 && ((List <String>)unicorn.Value).Contains("Email's ending isn't valid")))
            {
                logged = aUser.login(Email, password); // create user if nothing disturbing
            }
            else if (((List <String>)unicorn.Value).Count != 0)
            {
                throw unicorn;
            }
        }
예제 #2
0
        private static Boolean CheckEmailValid(String email)
        {
            if (email == null || email.Length == 0)
            {
                MileStone4.DataAcces_Layer.Logger.Log.Error("the user " + email + " insert null password");
                return(false);
            }
            String ans = "";

            MileStone4.AlmogException unicorn = new MileStone4.AlmogException();
            unicorn.Value = new List <String>();
            try
            {
                String[] splitEmail = email.Split('@'); // split the check
                foreach (Char value in splitEmail[0])
                {                                       // is letter?
                    if (122 >= (int)value & (int)value >= 97)
                    {
                        ans += value;
                    }
                }
                if (ans != splitEmail[0])
                {
                    ((List <String>)unicorn.Value).Add("Username dosen't contains only letters");
                    ((List <String>)unicorn.Value).Add(ans);
                }
                if (splitEmail.Length == 1)
                {
                    ((List <String>)unicorn.Value).Add("Email's ending isn't valid");
                }
                else if (splitEmail.Length >= 2 && splitEmail[1] != "post.bgu.ac.il") // is it an email?
                {
                    ((List <String>)unicorn.Value).Add("Email isn't valid");
                }
            }
            catch (Exception e) // for anything else
            {
                String str = e.Message;
                ((List <String>)unicorn.Value).Add("Email isn't valid");
                MileStone4.DataAcces_Layer.Logger.Log.Error("User " + email + " cause error: " + e.Message);
            }
            if (((List <String>)unicorn.Value).Count != 0) // if there is message, inform
            {
                throw unicorn;
            }
            return(true);
        }
예제 #3
0
 private void ButtomCheck() // textbox valid check
 {
     MileStone4.AlmogException unicorn = new MileStone4.AlmogException();
     unicorn.Value = new List <String>();
     if (a.email == null)
     {
         ((List <String>)unicorn.Value).Add("Email empty");
     }
     if (a.password == null)
     {
         ((List <String>)unicorn.Value).Add("Password empty");
     }
     if (((List <String>)unicorn.Value).Count != 0)
     {
         throw unicorn;
     }
 }
예제 #4
0
        public static void registration(string Email, string password)
        {
            MileStone4.AlmogException unicorn = new MileStone4.AlmogException();
            unicorn.Value = new List <String>();
            aUser user = new User();

            if (!(CheckPassword(password))) // cheack valid
            {
                ((List <String>)unicorn.Value).Add("Password isn't valid");
            }
            try
            {
                CheckEmailValid(Email);
            }
            catch (MileStone4.AlmogException e)
            {
                for (int i = 0; i < ((List <String>)e.Value).Count; i++)
                {
                    ((List <String>)unicorn.Value).Add(((List <String>)e.Value)[i]);
                }
            }
            if (((List <String>)unicorn.Value).Count != 0)
            {
                throw unicorn;
            }

            if (user.CheckEmailUnuiqeness(Email))
            {
                user.Registration(Email, password);
            }
            else
            {
                ((List <String>)unicorn.Value).Add("Email already exists");
            }

            if (((List <String>)unicorn.Value).Count != 0)
            {
                throw unicorn;
            }
        }
예제 #5
0
        private void ButtomCheck() // textbox valid check
        {
            String pass  = "******";
            String passC = "t";

            MileStone4.AlmogException unicorn = new MileStone4.AlmogException();
            unicorn.Value = new List <String>();
            if (a.email == null)
            {
                ((List <String>)unicorn.Value).Add("Email empty");
            }
            if (a.password == null)
            {
                ((List <String>)unicorn.Value).Add("Password empty");
            }
            else
            {
                pass = a.password;
            }
            if (a.passwordC == null)
            {
                ((List <String>)unicorn.Value).Add("PasswordC empty");
            }
            else
            {
                passC = a.passwordC;
            }
            if (!(pass.Equals(passC)) & (pass != "c") & (passC != "t"))
            {
                ((List <String>)unicorn.Value).Add("Password isn't confirm");
            }
            if (((List <String>)unicorn.Value).Count != 0)
            {
                throw unicorn;
            }
        }