Example #1
0
        [InlineData("Seller1", "seller123")] // Password Correct
        public void Login_As_Seller_ShouldBeValid(string login, string password)
        {
            var user   = service.Login(login, CryptMD5.Generate(password));
            var result = user != null && user.Id > 0;

            result.Should().BeTrue();
        }
Example #2
0
        [InlineData("Administrator", "admin12345")] // Password Incorret
        public void Login_As_Admin_ShouldBeInvalid(string login, string password)
        {
            var user   = service.Login(login, CryptMD5.Generate(password));
            var result = user != null && user.Id > 0;

            result.Should().BeFalse();
        }
        public async Task <ResponseResult> Login(UserSysDto userSysDto)
        {
            var userLogin = new UserSys {
                Login = userSysDto.Login, Password = CryptMD5.Generate(userSysDto.Password)
            };
            var userSys = await userSysService.Login(userLogin);

            if (userSys != null && userSys.Id > 0)
            {
                userSysDto          = mapper.Map <UserSysDto>(userSys);
                userSysDto.Password = "";
                var response = new BaseResponse(userSysDto, "Authentication successful!");

                return(await response.Result);
            }

            return(await new BaseResponse(userSysDto.Login, false, "The email and/or password entered is invalid. Please try again.").Result);
        }