Beispiel #1
0
        public async Task <ActionResult> Login([FromBody] SessionLoginRequest loginRequest)
        {
            var result = await loginUserInteractor.Handle(new UserCredentials(loginRequest.Username, loginRequest.Password));

            return(result.Match <ActionResult>(
                       login => login != null ? Ok(login) : Unauthorized("Invalid username and/or password") as ActionResult,
                       fail => BadRequest(fail)
                       ));
        }
        public async Task <IActionResult> Login([FromBody] SessionLoginRequest loginRequest)
        {
            UserLogin?login = null;

            bus.Listen <UserLoginEvent>((IDomainEvent e) => {
                UserLoginEvent loginEvent = (UserLoginEvent)e;
                login = loginEvent.Login;
            });

            var result = await mediator.Command(new LoginUserCommand()
            {
                Credentials = new UserCredentials(loginRequest.Username, loginRequest.Password)
            });

            return(login != null?Ok(login) : Unauthorized("Invalid username and/or password.") as IActionResult);
        }