Beispiel #1
0
        private void Login()
        {
            ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;

            ApplicationVM.token = GetToken();

            if (!ApplicationVM.token.IsError)
            {
                GetOrganisation();
                appvm.ChangePage(new MainscreenVM());
            }
            else
            {
                Error = "Gebruikersnaam of paswoord kloppen niet";
                ApplicationVM.CurrentOrganisation = null;
            }
        }
        private async void UpdatePassword()
        {
            if (Cryptography.Encrypt(Username) == ApplicationVM.CurrentOrganisation.Login && Cryptography.Encrypt(OldPassword) == ApplicationVM.CurrentOrganisation.Password)
            {
                Organisations o = ApplicationVM.CurrentOrganisation;
                o.Password = Cryptography.Encrypt(NewPassword);
                string input = JsonConvert.SerializeObject(o);
                using (HttpClient client = new HttpClient())
                {
                    client.SetBearerToken(ApplicationVM.token.AccessToken);
                    HttpResponseMessage response = await client.PostAsync("http://localhost:3655/api/organisation/", new StringContent(input, Encoding.UTF8, "application/json"));

                    if (response.IsSuccessStatusCode)
                    {
                        ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;
                        appvm.ChangePage(new MainscreenVM());
                    }
                }
            }
            else
            {
                Error = "Gebruikersnaam of wachtwoord klopt niet";
            }
        }