Beispiel #1
0
        public async Task <ServerConnection> TryConnect(Uri uri)
        {
            var restClient = _restClientFactory.Create(uri);
            var result     =
                await AuthenticationResource.Authenticate(_clientInfoProvider.GetAuthenticationDto(), restClient);

            restClient.SetAuthenticated(result.Jwt);

            return(new ServerConnection(restClient, result.Modules, _options));
        }
        public async Task <IActionResult> Authenticate([FromBody] AuthenticationResource authenticationResource)
        {
            var token = await _authenticationService.GetToken(authenticationResource.Username,
                                                              authenticationResource.Password);

            if (token == null)
            {
                return(new UnauthorizedResult());
            }

            return(new JsonResult(token));
        }