public void EnumerableConstructor_AssignsArgumentToListOfLogins()
        {
            var list = new List <Login>(4);

            list.Add(new Login("id1", "pwd1"));
            list.Add(new Login("id2", "pwd2"));
            list.Add(new Login("id3", "pwd3"));
            list.Add(new Login("id4", "pwd4"));

            var container = new LoginContainer(list);

            Assert.AreSame(list, container.Logins);
        }
        private async Task ValidLoginAnimation()
        {
            await LoginContainer.FadeTo(0, 250);

            AnimationView.Opacity = 1;
            await AnimationView.TranslateTo(0, 0, 2000, Easing.SinInOut);

            ConfettiView.Opacity = 1;
            ConfettiView.Play();
            ConfettiView.OnFinish += ConfettiView_OnFinish;
            await Task.Delay(1000);

            await AnimationView.TranslateTo(300, 0, 2000, Easing.SinInOut);

            AnimationView.Opacity = 0;
        }
Ejemplo n.º 3
0
        private void SetResources()
        {
            //login control
            ((Label)LoginContainer.FindControl("lblUsername")).Text   = Resources.Account_Strings.Label_Username;
            ((Label)LoginContainer.FindControl("lblPassword")).Text   = Resources.Account_Strings.Label_Password;
            ((Label)LoginContainer.FindControl("lblRememberMe")).Text = Resources.Account_Strings.Label_RememberMe;
            ((Button)LoginContainer.FindControl("btnLogin")).Text     = Resources.Account_Strings.Button_Login;

            //failure text
            this.LoginContainer.FailureText = Resources.Account_Strings.Login_Failure;

            //link below login control
            this.lblDontHave.Text       = Resources.Account_Strings.Label_DontHaveAccount;
            this.RegisterHyperLink.Text = Resources.Account_Strings.Label_RegisterLink;
            this.linkResetPassword.Text = Resources.Account_Strings.Link_ResetPassword;
            this.lblResetPassword.Text  = Resources.Account_Strings.Label_ResetPassword;
        }
        private async Task InvalidLoginAnimation()
        {
            uint   speed  = 50;
            Easing easing = Easing.Linear;

            await LoginContainer.TranslateTo(-15, 0, speed, easing);

            await LoginContainer.TranslateTo(15, 0, speed, easing);

            await LoginContainer.TranslateTo(-10, 0, speed, easing);

            await LoginContainer.TranslateTo(+10, 0, speed, easing);

            await LoginContainer.TranslateTo(-5, 0, speed, easing);

            await LoginContainer.TranslateTo(5, 0, speed, easing);

            await LoginContainer.TranslateTo(0, 0, speed, easing);
        }
 public ActionResult Login(UserModel userModel)
 {
     if (ModelState.IsValid)
     {
         LoginContainer container = new LoginContainer {
         };
         userModel = new UserModel(container.Login(userModel.Email, userModel.Password));
         if (userModel.UniqueID != "0" && userModel.UniqueID != null)
         {
             Session["Login"]      = userModel;
             TempData["FirstName"] = userModel.FirstName;
             return(RedirectToAction("", "Home"));
         }
         else
         {
             return(View("LoginError"));
         }
     }
     return(View("Login"));
 }
Ejemplo n.º 6
0
    public void Login()
    {
        string email    = txtEmail.text;
        string password = txtPassword.text;

        if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
        {
            txtError.text = "*Email and Password can't be empty";
            return;
        }

        btnLogin.interactable = false;
        btnLoginText.text     = "Please Wait...";

        LiveAPI.Instance.Query(QueryType.GET_LOGIN, $"email={email}&password={password}", (res, err) =>
        {
            btnLogin.interactable = true;
            btnLoginText.text     = "Login";
            if (!string.IsNullOrEmpty(err))
            {
                Debug.Log(err);
                return;
            }

            LoginContainer login = JsonUtility.FromJson <LoginContainer>(res);
            if (login.status != "success")
            {
                Debug.Log(login.message);
                txtError.text = login.message;
                return;
            }

            PlayerData.loginData = login;
            PlayerPrefs.SetString("email", email);
            SceneManager.LoadScene("TermsConditions");
        }, null);
    }
Ejemplo n.º 7
0
        //stuff that controller shouldn't know
        // private bool verifyMessage(string message)
        // {
        //     JsonSerializerOptions serializerOptions = new JsonSerializerOptions();
        //     serializerOptions.Converters.Add(new BigIntegerConverter());
        //     Signature signature = JsonSerializer.Deserialize<Signature>(message, serializerOptions);
        //
        //     return Verifying.verifyMessage(signature, message, EncryptionVariables.PukForClients,
        //         EncryptionVariables.EllipticCurveForClient);
        // }

        // https://weblog.west-wind.com/posts/2017/sep/14/accepting-raw-request-body-content-in-aspnet-core-api-controllers
        // public static async Task<string> GetRawBodyStringAsync(this HttpRequest request, Encoding encoding = null)
        // {
        //     if (encoding == null)
        //         encoding = Encoding.UTF8;
        //
        //     using (StreamReader reader = new StreamReader(request.Body, encoding))
        //         return await reader.ReadToEndAsync();
        // }


        private string loginClientToLoginServer(string message)
        {
            JsonSerializerOptions serializerOptions = new JsonSerializerOptions();

            serializerOptions.Converters.Add(new BigIntegerConverter());

            LoginContainer     loginContainer = JsonSerializer.Deserialize <LoginContainer>(message, serializerOptions);
            EllipticCurvePoint sharedKey      = KeyGeneration.calculateMasterKey(EncryptionVariables.PrkcForClient,
                                                                                 loginContainer.clientPuk, EncryptionVariables.EllipticCurveForClient);
            ECIESUnprocessResult unprocessResult = ECIESProvider.unprocessMessage(sharedKey.x.ToString(),
                                                                                  loginContainer.loginPackage.Tag, loginContainer.loginPackage.EncryptedMessage);

            if (unprocessResult.Status != MyEnum.Successful)
            {
                return(JsonSerializer.Serialize(new LoginResultContainer()
                {
                    LoginResultECIESProcessed = ECIESProvider.processMessage(sharedKey.x.ToString(),
                                                                             JsonSerializer.Serialize(new LoginResult()
                    {
                        Status = 401
                    }))
                }));
            }
            else
            {
                LoginPackage loginPackage =
                    JsonSerializer.Deserialize <LoginPackage>(unprocessResult.DeprocessedMessage);
                LoginResult loginResult = _login.login(loginPackage);

                return(JsonSerializer.Serialize(new LoginResultContainer()
                {
                    LoginResultECIESProcessed = ECIESProvider.processMessage(sharedKey.x.ToString(),
                                                                             JsonSerializer.Serialize(loginResult))
                }));
            }
        }
Ejemplo n.º 8
0
        void ReleaseDesignerOutlets()
        {
            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

            if (BackgroundImageView != null)
            {
                BackgroundImageView.Dispose();
                BackgroundImageView = null;
            }

            if (ConfirmPasswordTextField != null)
            {
                ConfirmPasswordTextField.Dispose();
                ConfirmPasswordTextField = null;
            }

            if (CreateAccountButton != null)
            {
                CreateAccountButton.Dispose();
                CreateAccountButton = null;
            }

            if (EmailTextField != null)
            {
                EmailTextField.Dispose();
                EmailTextField = null;
            }

            if (EmailTextFieldOfForgetPassword != null)
            {
                EmailTextFieldOfForgetPassword.Dispose();
                EmailTextFieldOfForgetPassword = null;
            }

            if (EmailTextFieldOfRegistration != null)
            {
                EmailTextFieldOfRegistration.Dispose();
                EmailTextFieldOfRegistration = null;
            }

            if (ErrorMessageLabel != null)
            {
                ErrorMessageLabel.Dispose();
                ErrorMessageLabel = null;
            }

            if (FirstNameTextField != null)
            {
                FirstNameTextField.Dispose();
                FirstNameTextField = null;
            }

            if (ForgetPasswordButton != null)
            {
                ForgetPasswordButton.Dispose();
                ForgetPasswordButton = null;
            }

            if (ForgetPasswordContainer != null)
            {
                ForgetPasswordContainer.Dispose();
                ForgetPasswordContainer = null;
            }

            if (LastNameTextField != null)
            {
                LastNameTextField.Dispose();
                LastNameTextField = null;
            }

            if (LoadingIndicator != null)
            {
                LoadingIndicator.Dispose();
                LoadingIndicator = null;
            }

            if (LoginButton != null)
            {
                LoginButton.Dispose();
                LoginButton = null;
            }

            if (LoginContainer != null)
            {
                LoginContainer.Dispose();
                LoginContainer = null;
            }

            if (PasswordTextField != null)
            {
                PasswordTextField.Dispose();
                PasswordTextField = null;
            }

            if (PasswordTextFieldOfRegistration != null)
            {
                PasswordTextFieldOfRegistration.Dispose();
                PasswordTextFieldOfRegistration = null;
            }

            if (RegistrationButton != null)
            {
                RegistrationButton.Dispose();
                RegistrationButton = null;
            }

            if (RegistrationContainer != null)
            {
                RegistrationContainer.Dispose();
                RegistrationContainer = null;
            }

            if (ResetPasswordButton != null)
            {
                ResetPasswordButton.Dispose();
                ResetPasswordButton = null;
            }

            if (WhatIsSeekiosButton != null)
            {
                WhatIsSeekiosButton.Dispose();
                WhatIsSeekiosButton = null;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// <para>Creates a new account using the following variables: NomUser, Email and Password</para>
        /// <para>Error handling is Api side, so just catch the response in a try-catch</para>
        /// </summary>
        /// <param name="Username">Must be unique.</param>
        /// <param name="Email">Must be unique</param>
        /// <param name="Password">At least 1 character long.</param>
        /// <returns>True if the account was created successfully.</returns>
        public static async Task <bool> CreateNewAccount(string Username, string Email, string Password)
        {
            if (Misc.Utils.IsValidEmail(Email) && !Username.Equals("") && !Password.Equals(""))
            {
                LoginClass     L  = new LoginClass();
                LoginContainer LC = new LoginContainer();
                try
                {
                    string passwordSHA256 = Misc.Utils.GenerateSHA256String(Password);
                    string L_obj          = "";
                    L.Username = Username;
                    L.Email    = Email;
                    L.Password = passwordSHA256;
                    L_obj      = L_obj + JsonConvert.SerializeObject(L, Formatting.Indented);

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(Constants.URL + "/api.savecentral.com/v1/users/register"));
                    request.Accept      = "application/json";
                    request.ContentType = "application/json";
                    request.Method      = "POST";

                    byte[] byteArray = Encoding.UTF8.GetBytes(L_obj);
                    request.ContentLength = byteArray.Length;
                    using (Stream DataStream = await request.GetRequestStreamAsync())
                    {
                        DataStream.Write(byteArray, 0, byteArray.Length);
                        DataStream.Close();

                        using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
                        {
                            using (Stream ResponseStream = response.GetResponseStream())
                            {
                                using (StreamReader sr = new StreamReader(ResponseStream))
                                {
                                    string ServerResponse = await sr.ReadToEndAsync();

                                    LC = JsonConvert.DeserializeObject <LoginContainer>(ServerResponse);
                                    //Success
                                    await SendMail.Send(Username, Email, Password);

                                    MessageBox.Show(LC.message);
                                    return(true);
                                }
                            }
                        }
                    }
                }
                catch (WebException e)
                {
                    if (e.Response != null)
                    {
                        using (var errorResponse = (HttpWebResponse)e.Response)
                        {
                            using (var reader = new StreamReader(errorResponse.GetResponseStream()))
                            {
                                string error = reader.ReadToEnd();
                                LC = JsonConvert.DeserializeObject <LoginContainer>(error);
                                if (LC.message.Contains("SQLSTATE[23000]: Integrity constraint violation"))
                                {
                                    MessageBox.Show("Username or Email already exist.");
                                }
                                else
                                {
                                    MessageBox.Show(LC.message);
                                }

                                return(false);
                            }
                        }
                    }
                    return(false);
                }
            }
            else
            {
                MessageBox.Show("El usuario, contraseña o email introducidos no son válidos. Debes introducir un email válido y el usuario y contraseña no pueden estar vacios.");
                return(false);
            }
        }
Ejemplo n.º 10
0
        public static async Task <bool> ChkIfLoginPass(string User, string Password, Label lblSessionStatus)
        {
            LoginClass     L  = new LoginClass();
            LoginContainer LC = new LoginContainer();

            try
            {
                lblSessionStatus.Content    = "Iniciando sesión...";
                lblSessionStatus.Background = Brushes.AliceBlue;

                string passwordSHA256 = Misc.Utils.GenerateSHA256String(Password);

                string L_obj = "";
                L.UsernameOrEmail = User;
                L.Password        = passwordSHA256;
                L_obj             = L_obj + JsonConvert.SerializeObject(L, Formatting.Indented);

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(Constants.URL + "/api.savecentral.com/v1/users/login"));
                request.Accept      = "application/json";
                request.ContentType = "application/json";
                request.Method      = "POST";

                byte[] byteArray = Encoding.UTF8.GetBytes(L_obj);
                request.ContentLength = byteArray.Length;
                using (Stream DataStream = await request.GetRequestStreamAsync())
                {
                    DataStream.Write(byteArray, 0, byteArray.Length);
                    DataStream.Close();

                    using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
                    {
                        using (Stream ResponseStream = response.GetResponseStream())
                        {
                            using (StreamReader sr = new StreamReader(ResponseStream))
                            {
                                string ServerResponse = sr.ReadToEnd();
                                LC = JsonConvert.DeserializeObject <LoginContainer>(ServerResponse);
                                Constants.ApiKey            = LC.user.ApiKey;
                                Constants.User              = LC.user.Username;
                                lblSessionStatus.Content    = Constants.lblLogin + LC.user.Username;
                                lblSessionStatus.FontWeight = FontWeights.Bold;
                                lblSessionStatus.Background = Brushes.LightGreen;
                                return(true);
                            }
                        }
                    }
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                    using (var errorResponse = (HttpWebResponse)e.Response)
                    {
                        using (var reader = new StreamReader(errorResponse.GetResponseStream()))
                        {
                            string error = reader.ReadToEnd();
                            LC = JsonConvert.DeserializeObject <LoginContainer>(error);
                            //MessageBox.Show(LC.message);
                            Constants.ApiKey            = "";
                            Constants.User              = "";
                            lblSessionStatus.Content    = Constants.lblNoLoged;
                            lblSessionStatus.FontWeight = FontWeights.Bold;
                            lblSessionStatus.Background = Brushes.LightGray;
                            return(false);
                        }
                    }
                }
                Constants.ApiKey = "";
                Constants.User   = "";
                return(false);
            }
        }
        public void DefaultConstructor_InitializeListOfLogins()
        {
            var container = new LoginContainer();

            Assert.IsNotNull(container.Logins);
        }