Beispiel #1
0
        static void Main(string[] args)
        {
            if (!Directory.Exists(Settings.Default.ExportPath))
            {
                Console.WriteLine(string.Format("Export path doesn't exist : {0}", Settings.Default.ExportPath));

                return;
            }

            _url = Settings.Default.ApiUrl;

            _startDate = DateTime.Now.Subtract(TimeSpan.FromDays(1));
            _endDate   = DateTime.Now;

            try
            {
                var auth     = new AuthServiceClient(_url, null, null, null, null);
                var response = auth.Authenticate(Settings.Default.Username, Settings.Default.Password);
                response.Wait();
                _token = response.Result;
            }
            catch
            {
                Console.WriteLine(string.Format("Verify your admin credentials, user {0} and password {1} are invalid", Settings.Default.Username, Settings.Default.Password));
                return;
            }

            ExportOrders();
        }
Beispiel #2
0
        public async Task <ActionResult> Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (AuthServiceClient client = new AuthServiceClient())
                {
                    UserDTO userDTO = new UserDTO {
                        Email = model.Email, Password = model.Password
                    };
                    ClaimsIdentity claim = await Task.Run(() => client.Authenticate(userDTO));

                    if (claim == null)
                    {
                        ModelState.AddModelError("", "Incorrect password or login");
                    }
                    else
                    {
                        AuthMng.SignOut();
                        AuthMng.SignIn(new AuthenticationProperties
                        {
                            IsPersistent = true
                        }, claim);

                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }
            return(View(model));
        }
        public bool VerifyUser(string UserName, string Password)
        {
            int _cim = int.Parse(UserName);

            // Use User Verification Service
            AuthServiceClient authService = new AuthServiceClient();

            return(authService.Authenticate(_cim, Password));
        }
Beispiel #4
0
        public async void when_user_sign_in()
        {
            var sut      = new AuthServiceClient(BaseUrl, null, new DummyPackageInfo(), null, null);
            var response = await sut.Authenticate(TestAccount.Email, TestAccountPassword);

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.SessionId, "Test");
            Assert.AreEqual(TestAccount.Email, response.UserName);
        }
        public bool VerifyUser(string UserName, string Password)
        {
            int _cim = int.Parse(UserName);

            // Use User Verification Service
            AuthServiceClient authService = new AuthServiceClient();

            return authService.Authenticate(_cim, Password);
        }
Beispiel #6
0
        public void when_user_sign_in_with_invalid_email()
        {
            var sut = new AuthServiceClient(BaseUrl, null, new DummyPackageInfo(), null, null);

            Assert.Throws <WebServiceException>(async() => await sut.Authenticate("*****@*****.**", TestAccountPassword), "InvalidLoginMessage");
        }