Exemplo n.º 1
0
        // GET: AdministratorNovosti/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _novosti.Pristupi(korisnik);

            ViewData["Ime"] = korisnik.Ime;

            if (id == null)
            {
                return(NotFound());
            }

            var novost = await _novosti.DajNovost(id);

            if (novost == null)
            {
                return(NotFound());
            }

            return(View(novost));
        }
        public async Task <IActionResult> Create([Bind("Id,SaRacuna,NaRacun,Vrijeme,Iznos,VrstaTransakcije,NacinTransakcije")] Transakcija transakcija)
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _transakcije.Pristupi(korisnik);
            _racuni.Pristupi(korisnik);

            transakcija.SaRacuna = await _racuni.DajRacun(transakcija.SaRacuna.Id);

            if (transakcija.NacinTransakcije == NacinTransakcije.Interna)
            {
                transakcija.NaRacun = await _racuni.DajRacun(transakcija.NaRacun.Id);
            }
            else
            {
                transakcija.NaRacun = await _racuni.DajRacun(4);
            }

            if (transakcija.SaRacuna.StanjeRacuna < transakcija.Iznos)
            {
                return(RedirectToAction(nameof(Create), new { area = "nemaSredstava" }));
            }

            await _transakcije.Uplati(transakcija);

            return(RedirectToAction("Index", "KlijentHome", new { area = "" }));
        }
        // GET: Filijala/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _filijaleBankomati.Pristupi(korisnik);
            ViewData["Ime"] = korisnik.Ime;
            if (id == null)
            {
                return(NotFound());
            }

            var filijala = await _filijaleBankomati.DajFilijalu(id);

            if (filijala == null)
            {
                return(NotFound());
            }

            return(View(filijala));
        }
Exemplo n.º 4
0
        public void HashingIsApplied()
        {
            var input  = "123";
            var output = LoginUtils.MakeHash(input);

            Assert.NotEqual(input, output);
        }
Exemplo n.º 5
0
        public ActionResult Logar(String usuario, String senha)
        {
            LoginUtils.Logar(usuario, senha);

            if (LoginUtils.Login.permissao == true)
            {
                return(RedirectToAction("AreaAdministrador", "Admin"));
            }
            else if (LoginUtils.Login.permissao == false)
            {
                if (LoginUtils.Carrinho != null)
                {
                    foreach (Carrinho c in LoginUtils.Carrinho)
                    {
                        c.Id      = new Guid();
                        c.cliente = LoginUtils.Cliente;
                        DbFactory.Instance.CarrinhoRepository.SaveOrUpdate(c);
                    }
                }

                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }
Exemplo n.º 6
0
        // GET: AdministratorBankari/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _bankari.Pristupi(korisnik);
            ViewData["Ime"] = korisnik.Ime;

            if (id == null)
            {
                return(NotFound());
            }

            var bankar = await _bankari.DajBankara(id);

            if (bankar == null)
            {
                return(NotFound());
            }

            return(View(bankar));
        }
        // GET: BankarTransakcije/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _transakcije.Pristupi(korisnik);

            ViewData["Ime"] = korisnik.Ime;

            if (id == null)
            {
                return(NotFound());
            }

            var transakcija = await _transakcije.DajTransakciju(id);

            if (transakcija == null)
            {
                return(NotFound());
            }

            return(View(transakcija));
        }
Exemplo n.º 8
0
 public void UpdateUserView()
 {
     handler.Post(async() =>
     {
         if (LoginUtils.Instance(this).GetLoginStatus())
         {
             var user             = await LoginUtils.Instance(this).GetUser();
             Author.Text          = user.DisplayName;
             Seniority.Text       = Resources.GetString(Resource.String.seniority) + ":" + user.Seniority;
             txtLogout.Visibility = ViewStates.Visible;
             Picasso.With(this)
             .Load(user.Avatar)
             .Placeholder(Resource.Drawable.placeholder)
             .Error(Resource.Drawable.placeholder)
             .Transform(new CircleTransform())
             .Into(Avatar);
         }
         else
         {
             Author.Text          = Resources.GetString(Resource.String.need_login);
             Seniority.Text       = "";
             txtLogout.Visibility = ViewStates.Gone;
             Picasso.With(this)
             .Load(Resource.Drawable.placeholder)
             .Placeholder(Resource.Drawable.placeholder)
             .Error(Resource.Drawable.placeholder)
             .Transform(new CircleTransform())
             .Into(Avatar);
         }
     });
 }
        public void Run()
        {
            this.Storage.Initialize();
            this.TransactionPool.WipeThread.Start();
            Log.Info(String.Format("Engine starting running(version:{0})...",
                                   Assembly.GetAssembly(this.GetType()).GetName().Version));
            //F3Gate would start after successful log in.
            this.CloudParking.Start();
            Log.Info("Engine started!");
            this.UiControl.Dispatcher.Invoke(new Action(() =>
            {
                this.UiControl.MajorWindow.Show();
                this.UiControl.MajorWindow.MainPage.ParkPage.RefreshData
                (
                    this.Storage.GetTodayParking()
                );
                this.UiControl.MajorWindow.MainPage.TicketPage.RefreshData
                (
                    this.Storage.GetTodayTicketUsed()
                );
                this.UiControl.LoginWindow.Owner = this.UiControl.MajorWindow;
                this.UiControl.LoginWindow.UserNameTextBox.Text =
                    LoginUtils.ReadPerservedAccount(
                        new FileInfo(FileConfig.FindConfig("GUI.cfg").GetString("PERSERVEACCOUNTFILENAME"))).Item1;
                this.UiControl.LoginWindow.PasswordTextBox.Password =
                    LoginUtils.ReadPerservedAccount(
                        new FileInfo(FileConfig.FindConfig("GUI.cfg").GetString("PERSERVEACCOUNTFILENAME"))).Item2;

                this.UiControl.LoginWindow.ShowDialog();
            }));
            this.UiControl.Run();
        }
Exemplo n.º 10
0
        // GET: BankarZahtjevZaKredit/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _zahtjevi.Pristupi(korisnik);

            ViewData["Ime"] = korisnik.Ime;

            if (id == null)
            {
                return(NotFound());
            }

            var zahtjev = await _zahtjevi.DajZahtjev(id);

            if (zahtjev == null)
            {
                return(NotFound());
            }

            ViewData["kreditnaSposobnost"] = zahtjev.DajKreditnuSposobnost();

            return(View(zahtjev));
        }
        public async Task <IActionResult> Edit(int?id)
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _racuni.Pristupi(korisnik);


            if (id == null)
            {
                return(NotFound());
            }

            var racun = await _racuni.DajRacun(id);

            if (racun == null)
            {
                return(NotFound());
            }
            return(View(racun));
        }
Exemplo n.º 12
0
        private void LoginSuccess(LoginResult result)
        {
            Engine.GetEngine().UiControl.LoginWindow.Dispatcher.Invoke(new Action(() =>
            {
                Engine.GetEngine().UiControl.LoginWindow.ResultString  = UI.Properties.Resources.LoginSuccess;
                Engine.GetEngine().UiControl.LoginWindow.IsLoginEnable = true;
                Engine.GetEngine().UiControl.LoginWindow.Visibility    = Visibility.Collapsed;
            }));
            Engine.GetEngine().UiControl.LoginWindow.Dispatcher.Invoke(new Action(() =>
            {
                if (Engine.GetEngine().UiControl.LoginWindow.PerserverAccount)
                {
                    LoginUtils.PerserveUserNameAndPasswordToFile(
                        new FileInfo(FileConfig.FindConfig("GUI.cfg").GetString("PERSERVEACCOUNTFILENAME")),
                        Engine.GetEngine().UiControl.LoginWindow.UserNameTextBox.Text,
                        Engine.GetEngine().UiControl.LoginWindow.PasswordTextBox.Password);
                }
                else
                {
                    LoginUtils.PerserveUserNameAndPasswordToFile(
                        new FileInfo(FileConfig.FindConfig("GUI.cfg").GetString("PERSERVEACCOUNTFILENAME")),
                        String.Empty,
                        String.Empty);
                }
            }));

            Engine.GetEngine().F3Gate.Start();
            Engine.GetEngine().CloudParking.TickThread.Start();
        }
Exemplo n.º 13
0
        public ActionResult ApagarProdutoCarrinho(Carrinho carrinho)
        {
            if (LoginUtils.Cliente != null)
            {
                DbFactory.Instance.CarrinhoRepository.Delete(carrinho);
            }
            else
            {
                Carrinho produto = new Carrinho();

                foreach (Carrinho c in Carrinho)
                {
                    if (c.Id == carrinho.Id)
                    {
                        produto = c;
                    }
                }

                Carrinho.Remove(produto);
            }

            LoginUtils.MeuCarrinho(Carrinho);

            return(RedirectToAction("MeuCarrinho"));
        }
Exemplo n.º 14
0
        private void ProcessRequest(SignIn model)
        {
            BlueGreenContext bgContext;
            string           redirect = LoginUtils.VacationsRedirect(Request.Url.Host.ToLower());

            if (String.IsNullOrEmpty(redirect))
            {
                Response.Redirect(redirect);
            }


            string referrer = Request.ServerVariables["HTTP_REFERER"];

            if (LoginUtils.IsBgvfsReferrer(referrer))
            {
                bgContext = new BlueGreenContext();
                //bgContext.DigestRequest();
            }

            if (SetPostData(model))
            {
                HandleRedirects(model);
            }


            bgContext = new BlueGreenContext();
            //bgContext.CleanSession();
        }
        public ActionResult LogOn(AccountModel accountModel)
        {
            var adm  = AccountDataMapper.GetAccountDataMapper();
            var user = adm.GetById(accountModel.Username.ToLower());

            if (user != null)
            {
                if (!user.Confirmed)
                {
                    ModelState.AddModelError("Username", "O username inserido ainda não foi confirmado. Por favor confirme através do seu email.");
                }
                else if (LoginUtils.ComparePasswords(accountModel.Password, user))
                {
                    FormsAuthentication.SetAuthCookie(user.Username, false);
                    return(RedirectToAction("Index", "Home", user));
                }
                /* Login Failed */
                else
                {
                    ModelState.AddModelError("Password", "A password inserida não é valida");
                }
            }
            else/*User not found. Please register*/
            {
                ModelState.AddModelError("Username", "O username inserido não corresponde a nenhum utilizador registado.");
            }
            return(View(accountModel));
        }
Exemplo n.º 16
0
 protected virtual async void acessarContaClicked(object sender, EventArgs e)
 {
     var loginPage = LoginUtils.gerarLogin(() => {
         executarLogin();
     });
     await Navigation.PushAsync(loginPage);
 }
Exemplo n.º 17
0
        // GET: KlijentProfil
        public async Task <IActionResult> Index()
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _klijenti.Pristupi(korisnik);
            _transakcije.Pristupi(korisnik);
            _krediti.Pristupi(korisnik);

            ViewData["Id"] = korisnik.Id;


            var klijent = await _klijenti.DajKlijenta(korisnik.Id);

            if (klijent == null)
            {
                return(NotFound());
            }

            ViewData["transakcije"] = await _transakcije.DajTransakcije(korisnik.Id);

            ViewData["racuni"] = await _racuni.DajRacune(korisnik.Id);

            ViewData["krediti"] = await _krediti.DajSveKrediteKlijenta(korisnik.Id);

            return(View(klijent));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,StanjeRacuna")] Racun racun)
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _racuni.Pristupi(korisnik);

            if (id != racun.Id)
            {
                return(NotFound());
            }


            try
            {
                await _racuni.UrediStanjeRacuna(racun);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RacunExists(racun.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 19
0
        public ActionResult Logout()
        {
            ReturnObject ro = new ReturnObject();

            LoginUtils.Logout();
            return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(ro)));
        }
Exemplo n.º 20
0
        public static async Task <HttpClient> CreateClient()
        {
            var client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:8080/");
            await Auth.AuthorizeClient(client, "1", LoginUtils.MakePasswordHash("1", "1"));

            return(client);
        }
Exemplo n.º 21
0
        public override async void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            try
            {
                this.HasOptionsMenu = true;
                swipeRefreshLayout  = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
                swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);
                swipeRefreshLayout.SetOnRefreshListener(this);

                recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
                var manager = new LinearLayoutManager(this.Activity);
                recyclerView.SetLayoutManager(manager);

                adapter = new StatusAdapter();
                adapter.SetOnLoadMoreListener(this);
                adapter.OnDeleteClickListener = this;
                adapter.User = await SQLiteUtils.Instance().QueryUser();

                recyclerView.SetAdapter(adapter);

                nologinView        = this.Activity.LayoutInflater.Inflate(Resource.Layout.nologin_view, (ViewGroup)recyclerView.Parent, false);
                nologinView.Click += delegate(object sender, EventArgs e)
                {
                    StartActivityForResult(new Intent(this.Activity, typeof(AuthorizeActivity)), (int)RequestCode.LoginCode);
                };
                notDataView        = this.Activity.LayoutInflater.Inflate(Resource.Layout.empty_view, (ViewGroup)recyclerView.Parent, false);
                notDataView.Click += delegate(object sender, EventArgs e)
                {
                    OnRefresh();
                };
                errorView        = this.Activity.LayoutInflater.Inflate(Resource.Layout.error_view, (ViewGroup)recyclerView.Parent, false);
                errorView.Click += delegate(object sender, EventArgs e)
                {
                    OnRefresh();
                };
                recyclerView.Post(async() =>
                {
                    if (position == 0)
                    {
                        await statusesPresenter.GetClientStatus();
                    }
                    else if (!LoginUtils.Instance(this.Activity).GetLoginStatus())
                    {
                        recyclerView.Post(() =>
                        {
                            adapter.SetEmptyView(nologinView);
                        });
                    }
                });
            }
            catch (Exception ex)
            {
                MobclickAgent.ReportError(Context, ex.Message + ex.StackTrace);
            }
        }
        public async Task <IActionResult> Index()
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }
            ViewData["Ime"] = korisnik.Ime;
            return(View(korisnik));
        }
Exemplo n.º 23
0
 public void TryLogin(string login, string password, Action <bool, string> onComplete)
 {
     Login    = login;
     Password = password;
     Log.MessageFormat("TryLogin: login: '******', password: '******'", LogTags.Auth, login, password);
     if (!_client.InProgress)
     {
         var passwordHash = LoginUtils.MakePasswordHash(login, password);
         var request      = CardUrl.Prepare(_authUrl, login, passwordHash);
         _client.SendGetRequest(request, onComplete: resp => OnLoginComplete(resp, onComplete));
     }
 }
Exemplo n.º 24
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            handler = new Handler();
            fm      = SupportFragmentManager;

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            toolbar.SetOnMenuItemClickListener(this);

            coordinatorLayout = FindViewById <CoordinatorLayout>(Resource.Id.coordinatorLayout);

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawerLayout);
            navigationView = FindViewById <NavigationView>(Resource.Id.navigationview);
            var headerLayout = navigationView.InflateHeaderView(Resource.Layout.header_layout);

            navigationView.InflateMenu(Resource.Menu.main);
            navigationView.SetNavigationItemSelectedListener(this);
            Avatar = headerLayout.FindViewById <ImageView>(Resource.Id.headerAvatar);
            Avatar.SetOnClickListener(this);
            Author           = headerLayout.FindViewById <TextView>(Resource.Id.headerAuthor);
            Seniority        = headerLayout.FindViewById <TextView>(Resource.Id.headerSeniority);
            txtLogout        = headerLayout.FindViewById <TextView>(Resource.Id.headerLogout);
            txtLogout.Click += delegate
            {
                LoginUtils.Instance(this).DeleteUser();
                UpdateUserView();
            };

            drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, Resource.String.drawer_open, Resource.String.drawer_close);
            drawerLayout.AddDrawerListener(this);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            StatusBarCompat.SetDrawerToolbarTabLayout(this, coordinatorLayout);

            UpdateUserView();

            navigationView.Post(() =>
            {
                SwitchNavigationBar(Resource.Id.home);
            });

            updManager = IFlytekUpdate.GetInstance(this.ApplicationContext);
            updManager.SetDebugMode(true);
            updManager.SetParameter(UpdateConstants.ExtraWifionly, "true");
            updManager.SetParameter(UpdateConstants.ExtraNotiIcon, "true");
            updManager.SetParameter(UpdateConstants.ExtraStyle, UpdateConstants.UpdateUiDialog);
            updManager.AutoUpdate(this, this);

            shareAction = new ShareAction(this).SetDisplayList(SHARE_MEDIA.Weixin, SHARE_MEDIA.WeixinCircle, SHARE_MEDIA.WeixinFavorite, SHARE_MEDIA.Sina).SetShareboardclickCallback(this);
        }
        // GET: Bankomat/Create
        public async Task <IActionResult> CreateAsync()
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _filijaleBankomati.Pristupi(korisnik);
            @ViewData["Ime"] = korisnik.Ime;
            return(View());
        }
        public ActionResult Logar(string usuario, string senha)
        {
            LoginUtils.Logar(usuario, senha);

            if (LoginUtils.Usuario != null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(RedirectToAction("EntrarUsuario"));
            }
        }
        private AccountDataMapper()
        {
            _accounts = new List <AccountModel>();
            /*Insert Data*/
            var am1 = new AccountModel {
                Username = "******", Email = "*****@*****.**", Password = "******", Confirmed = true
            };

            LoginUtils.EncryptPassword(am1);
            am1.Roles.Add("Admin");
            //----------------------
            var am2 = new AccountModel {
                Username = "******", Email = "*****@*****.**", Password = "******", Confirmed = true
            };

            LoginUtils.EncryptPassword(am2);
            am2.Roles.Add("Admin");
            //----------------------
            var am3 = new AccountModel {
                Username = "******", Email = "*****@*****.**", Password = "******", Confirmed = true
            };

            LoginUtils.EncryptPassword(am3);
            am3.Roles.Add("Admin");
            //----------------------
            var am4 = new AccountModel {
                Username = "******", Email = "*****@*****.**", Password = "******", Confirmed = true
            };

            LoginUtils.EncryptPassword(am4);
            am4.Roles.Add("Admin");
            //----------------------
            var am5 = new AccountModel {
                Username = "******", Email = "*****@*****.**", Password = "******", Confirmed = true
            };

            LoginUtils.EncryptPassword(am5);
            am5.Roles.Add("Admin");
            /*************************/
            var bm = BoardDataMapper.GetBoardDataMapper();

            am1.AddBoard(bm.GetById(1));
            am1.AddBoard(bm.GetById(2));
            _accounts.Add(am1);
            _accounts.Add(am2);
            _accounts.Add(am3);
            _accounts.Add(am4);
            _accounts.Add(am5);
        }
        // GET: BankarTransakcije
        public async Task <IActionResult> Index()
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _transakcije.Pristupi(korisnik);

            ViewData["Ime"] = korisnik.Ime;

            return(View(await _transakcije.DajSveTransakcije()));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _filijaleBankomati.Pristupi(korisnik);
            ViewData["Ime"] = korisnik.Ime;
            await _filijaleBankomati.UkloniBankomat(id);

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 30
0
        // GET: KlijentZahtjevZaKredit/Create
        public async Task <IActionResult> Create()
        {
            korisnik = await LoginUtils.Authenticate(Request, Context, this);

            if (korisnik == null)
            {
                return(RedirectToAction("Logout", "Login", new { area = "" }));
            }

            _zahtjevi.Pristupi(korisnik);
            _racuni.Pristupi(korisnik);
            ViewData["racuni"] = await _racuni.DajSveRacuneKlijenta(korisnik.Id);

            return(View());
        }