예제 #1
0
        public IActionResult SignIn(ClientEnterViewModel clientEnterViewModel)
        {
            var result   = _client.GetStringAsync("api/accounts").Result;
            var accounts = JsonConvert.DeserializeObject <List <AccountResource> >(result);
            var account  = accounts.Where(a => a.Login == clientEnterViewModel.Login).FirstOrDefault();

            result = _client.GetStringAsync("api/clients").Result;
            var clients = JsonConvert.DeserializeObject <List <ClientResource> >(result);
            var client  = clients.Where(c => c.AccountId == account.Id).FirstOrDefault();

            if (_encrypter.ValidatePassword(clientEnterViewModel.Password, account.Password))
            {
                try
                {
                    Response.Cookies.Append("clientId", client.Id.ToString());
                    return(Redirect("/site/vertical/index.html"));
                }
                catch (Exception)
                {
                    return(Redirect("/site/vertical/pages-login.html"));
                }
            }

            return(Redirect("/site/vertical/pages-login.html"));
        }
예제 #2
0
        public IActionResult SignIn(AccountSignInViewModel accountSignInViewModel)
        {
            var result   = _client.GetStringAsync("api/accounts").Result;
            var accounts = JsonConvert.DeserializeObject <List <AccountSignInViewModel> >(result);
            var account  = accounts.FirstOrDefault(a => a.Login == accountSignInViewModel.Login);

            if (account == null)
            {
                return(Redirect("/site/vertical/pages-login.html"));
            }

            if (_encrypter.ValidatePassword(accountSignInViewModel.Password, account.Password))
            {
                return(Redirect("/site/vertical/table-company.html"));
            }

            return(Redirect("/site/vertical/pages-login.html"));
        }