예제 #1
0
        async Task auth(bool is_admin)
        {
            MySQLServer.InputStatus status = await MySQLServer.login(loginBox.Value,
                                                                     passwordBox.Value,
                                                                     Response,
                                                                     is_admin);

            loginError.Text    = "<br />";
            passwordError.Text = "<br />";
            if (status == MySQLServer.InputStatus.LoginRequired)
            {
                loginError.Text = "Login required";
            }
            if (status == MySQLServer.InputStatus.PasswordRequired)
            {
                passwordError.Text = "Password required";
            }
            if (status == MySQLServer.InputStatus.NoSuchUser)
            {
                loginError.Text = "No such user";
            }
            if (status == MySQLServer.InputStatus.IncorrectPassword)
            {
                passwordError.Text = "Incorrect password";
            }
        }
        protected async void submit_Click(object sender, EventArgs e)
        {
            MySQLServer.InputStatus[] status = await MySQLServer.register(loginBox.Value,
                                                                          passwordBox.Value,
                                                                          emalBox.Value,
                                                                          Response);

            if (status[0] == MySQLServer.InputStatus.Succeed && status[0] == status[1] && status[0] == status[2])
            {
                await MySQLServer.login(loginBox.Value,
                                        passwordBox.Value,
                                        Response,
                                        false);
            }
            else
            {
                loginError.Text        = "This will be your username.";
                emailError.Text        = "We'll occasionally send updates about your account to this inbox.";
                passwordError.Text     = "Use at least one lowercase letter, one numeral, and seven characters.";
                loginError.CssClass    = "lower-text";
                emailError.CssClass    = "lower-text";
                passwordError.CssClass = "lower-text";
                if (status[0] == MySQLServer.InputStatus.LoginRequired)
                {
                    loginError.CssClass = "error-string";
                    loginError.Text     = "Login required";
                }
                if (status[1] == MySQLServer.InputStatus.EmailRequired)
                {
                    emailError.CssClass = "error-string";
                    emailError.Text     = "E-mail required";
                }
                if (status[2] == MySQLServer.InputStatus.PasswordRequired)
                {
                    passwordError.CssClass = "error-string";
                    passwordError.Text     = "Password required";
                }
                if (status[0] == MySQLServer.InputStatus.LoginAlreadyTaken)
                {
                    loginError.CssClass = "error-string";
                    loginError.Text     = "This login already taken";
                }
                if (status[1] == MySQLServer.InputStatus.EmailAlreadyTaken)
                {
                    emailError.CssClass = "error-string";
                    emailError.Text     = "This e-mail already taken";
                }
                if (status[2] == MySQLServer.InputStatus.ShortPassword)
                {
                    passwordError.CssClass = "error-string";
                    passwordError.Text     = "Password must be longer than 6 characters";
                }
            }
        }