Пример #1
0
        public async Task <Token> GetTokenAsync(string email, string password)
        {
            var userSignIn = new UserSignInRequestDto
            {
                Email    = email,
                Password = password
            };

            try
            {
                var tokenDto = await httpService.PostAsync <UserSignInRequestDto, TokenDto>(
                    AuthorizeEndpoint.Login, userSignIn);

                var token = AutoMapperConfiguration.Mapper.Map <Token>(tokenDto);

                return(token);
            }
            catch (System.Net.WebException ex)
            {
                throw new Exceptions.WebException("Server exception", ex);
            }
            catch (SocketException ex)
            {
                throw new Exceptions.WebException("Server exception", ex);
            }
        }
Пример #2
0
 public IActionResult UserSignIn([FromBody] UserSignInRequestDto message)
 {
     return(Ok(new UserSignInResponseDto()
     {
         ClientId = Config.ClientId,
         Scope = Config.AppAccessScope,
         ClientSecret = Config.ClientSecret,
         UriAuthorizationServer = "http://localhost:5010/connect/token",
         Valid = false,
         UserID = 11
     }));
 }
Пример #3
0
        public async Task <IActionResult> UserSignIn([FromBody] UserSignInRequestDto message)
        {
            if (await message.IsValid())
            {
                var response = await _policy.ExecuteAsync(async() => await _userSignInClient.Request(message));

                if (response != null)
                {
                    if (response.Valid)
                    {
                        response.ClientId               = Config.ClientId;
                        response.Scope                  = Config.AppAccessScope;
                        response.ClientSecret           = Config.ClientSecret;
                        response.UriAuthorizationServer = Startup.Configuration["url"] + "/connect/token";
                    }
                    return(Ok(response));
                }
            }
            return(BadRequest());
        }