예제 #1
0
        public async Task<IActionResult> Post([FromBody] UserResolver model)
        {
            if (string.IsNullOrEmpty(model.Email))
                NotifierError("email empty.");

            var response = new object();

            // Recupera o usuário
            var userApplication = await user.GetByEmail(model.Email);

            // Verifica se o usuário existe
            if (userApplication == null)
                NotifierError("user not found or without permission.");

            else
            {
                // Gera o Token
                model.Email = userApplication.Email.EmailAddress;
                var token = GenerateToken.GetToken(model);

                response = new
                {
                    email = model.Email,
                    name = userApplication.Name.FullName,
                    token = token
                };
            }


            return CustomResponse(response);
        }
예제 #2
0
        public void Get_User_Not_Found()
        {
            User user = null;

            mockRepository.FindOneAsync(Arg.Any <Expression <Func <User, bool> > >()).Returns(user);

            var notification = new Notification("");

            mockNotifier.Handle(notification);
            var erros = mockNotifier.GetNotifications();

            mockNotifier.HasNotification().Returns(true);

            appService.GetByEmail(Email_Invalido);

            Assert.True(mockNotifier.HasNotification());
        }