Esempio n. 1
0
        private async void ExecutePatternAsync(object item)
        {
            Pattern selectedPattern = item as Pattern;

            UserPassword.Value = await Application.Current.MainPage.DisplayPromptAsync("Подтверждение перевода", "Введите пароль");

            if (UserPassword.Value == null)
            {
                return;
            }
            if (UserPassword.Validate())
            {
                Tuple <bool, string> responseCheck = await UserService.Instance.Login(App.GetUser().login, UserPassword.Value);

                if (responseCheck.Item1 == true)
                {
                    string response = await TransactionService.Instance.DoTransfer(selectedPattern.from_, selectedPattern.to_, selectedPattern.amount);

                    await Application.Current.MainPage.DisplayAlert("Message", response, "OK");
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Message", "Неправильно введен пароль", "OK");
                }
            }
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseSession();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

            var optionsBuilder = new DbContextOptionsBuilder <MyDbContext>().UseSqlite(Configuration.GetConnectionString("Sqlite"));

            using (var myDbContext = new MyDbContext(optionsBuilder.Options))
            {
                var user = myDbContext.Users.FirstOrDefault();

                if (user == null)
                {
                    User firstUser = new User()
                    {
                        Id    = Guid.NewGuid(),
                        Name  = "teste",
                        Email = "*****@*****.**",
                    };

                    firstUser.Validate();
                    myDbContext.Users.Add(firstUser);

                    UserPassword userPassword = new UserPassword()
                    {
                        Id       = firstUser.Id,
                        UserId   = firstUser.Id,
                        Password = Cryptography.Encrypt(firstUser.Email + "teste"),
                    };

                    userPassword.Validate();
                    myDbContext.UsersPassword.Add(userPassword);

                    myDbContext.SaveChanges();
                }
            }
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Ativando middlewares para uso do Swagger
            app.UseSwagger();
            app.UseSwaggerUI(c => {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "RPEnglish.API V1");
            });

            app.UseCors("ApiCorsPolicy");

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            var optionsBuilder = new DbContextOptionsBuilder <MyDbContext>().UseSqlite(Configuration.GetConnectionString("Sqlite"));

            using (var myDbContext = new MyDbContext(optionsBuilder.Options))
            {
                var user = myDbContext.Users.FirstOrDefault();

                if (user == null)
                {
                    User firstUser = new User()
                    {
                        Id    = Guid.NewGuid(),
                        Name  = "teste",
                        Email = "*****@*****.**",
                    };

                    firstUser.Validate();
                    myDbContext.Users.Add(firstUser);

                    UserPassword userPassword = new UserPassword()
                    {
                        Id       = firstUser.Id,
                        UserId   = firstUser.Id,
                        Password = Cryptography.Encrypt(firstUser.Email + "teste"),
                    };

                    userPassword.Validate();
                    myDbContext.UsersPassword.Add(userPassword);

                    myDbContext.SaveChanges();
                }
            }
        }
Esempio n. 4
0
        public ViewResult ChangePassword(UserFull userModification, string OldPassword, string NewPassword, string ConfirmPassword)
        {
            UserPassword userPassword = new UserPassword(OldPassword, NewPassword, ConfirmPassword);

            var errors = userPassword.Validate();

            if (errors == null)
            {
                if (OldPassword != NewPassword)
                {
                    MembershipUser mu = Membership.GetUser();
                    if (!mu.ChangePassword(userPassword.OldPassword, userPassword.NewPassword))
                    {
                        errors = new ErrorSummary();
                        errors.RegisterErrorMessage("OldPassword", "The password that you enter is invalid");
                    }
                    else
                    {
                        userModification.Alert = "User password changed successfully";
                    }
                }
                else
                {
                    errors = new ErrorSummary();
                    errors.RegisterErrorMessage("NewPassword", "The New Password is same as the Old Password");
                }
            }

            if (errors != null)
            {
                Session["Errors"] = errors.ErrorMessages;
            }

            userModification.Tab = 2;
            userModification     = GetAccountData(userModification);
            return(View("Index", userModification));
        }