Esempio n. 1
0
        protected void loginButton_Click(object sender, EventArgs e)
        {
            string        email    = loginEmail.ToString().Length <= 0 ? "" : loginEmail.ToString();
            string        password = loginPassword.ToString().Length <= 0 ? "" : loginPassword.ToString();
            bool          error    = false;
            List <string> errors   = new List <string>();

            errorContainer.InnerHtml = "";

            if (email.Length <= 0)
            {
                //  Show error
                error = true;
                errors.Add("Email must be provided");
            }
            else if (password.Length <= 0)
            {
                //  Show error
                error = true;
                errors.Add("Password must be provided");
            }

            if (error == true)
            {
                errorContainer.InnerHtml += "<ul>";
                foreach (string err in errors)
                {
                    errorContainer.InnerHtml += "<li>" + err + "</li>";
                }
                errorContainer.InnerHtml += "</ul>";
                return;
            }

            login log = new login();

            log.user     = email;
            log.password = password;
            IuserClient client = new IuserClient();

            string response = client.userLogin(log);

            try
            {
                Session["userId"] = new Guid(response);
                //  Redirect to main page
                Server.Transfer("~/");
            }
            catch
            {
                //  Show error
            }
        }
Esempio n. 2
0
        protected void AccountRegister_Click(object sender, EventArgs e)
        {
            string response = "";
            int    error    = 0;

            if (userEmail.Value == null || userEmail.Value.Length <= 0)
            {
                response += "<li>Email Null</li>";
                error++;
            }

            if (userPassword.Value == null || userPassword.Value.Length <= 0)
            {
                response += "<li>PassWord Null</li>";
                error++;
            }
            else if (passwordConfirm.Value == null || passwordConfirm.Value.Length <= 0)
            {
                response += "<li>PassWord(2) Null</li>";
                error++;
            }

            if (error <= 0)
            {
                IuserClient user    = new IuserClient();
                register    regUser = new register();
                regUser.name      = "";
                regUser.firstname = "";
                regUser.lastname  = "";
                regUser.email     = userEmail.Value;
                regUser.password  = userPassword.Value;

                string userId = user.userRegister(regUser);
                try
                {
                    Guid userGuid = new Guid(userId);
                    Session["userId"] = userGuid.ToString();
                    response         += "<li>Account created succesfully</li>";
                }
                catch
                {
                    response += "<li>Error : " + userId + "</li>";
                }
            }
            createAccountLabel.InnerText = response;
        }
Esempio n. 3
0
        protected void registerButton_Click(object sender, EventArgs e)
        {
            var           email      = registerEmail.ToString();
            var           password   = registerPassword.ToString();
            var           rePassword = registerRePassword.ToString();
            List <string> errors     = new List <string>();
            bool          error      = false;

            errorContainer.InnerHtml = "";

            if (email.Length <= 0)
            {
                //  Show null error
                error = true;
                errors.Add("Email cannot be null");
            }

            if (password.Length < 8)
            {
                //  Show null error
                error = true;
                errors.Add("Password must be atleast 8 characters");
            }

            if (!password.All(char.IsDigit))
            {
                //  Password needs to contain digit
                error = true;
                errors.Add("Password must contain digit");
            }

            if (!password.All(c => char.IsUpper(c)))
            {
                //  Password needs to contain uppercase
                error = true;
                errors.Add("Password must contain uppercase");
            }

            if (rePassword.Length <= 0)
            {
                //  Show null error
                error = true;
                errors.Add("Password cannot be left null");
            }

            if (password != rePassword)
            {
                //  Show passwords dont match
                error = true;
                errors.Add("Passwords need to macth");
            }
            if (error == true)
            {
                errorContainer.InnerHtml += "<ul>";
                foreach (string err in errors)
                {
                    errorContainer.InnerHtml += "<li>" + err + "</li>";
                }
                errorContainer.InnerHtml += "</ul>";
                return;
            }

            register    reg      = new register();
            IuserClient user     = new IuserClient();
            string      response = user.userRegister(reg);

            try
            {
                Guid userId = new Guid(response);
            }
            catch
            {
                //  Show error
            }

            //  Redirect to "Check your email page"
            Server.Transfer("~/Account/register.aspx");
        }