Esempio n. 1
0
        public async Task <bool> CheckSmsUserIsAuthenticated(string userName)
        {
            var urlService = WebConfigurationManager.AppSettings["authRestServiceUrl"];

            HttpClient client = new HttpClient
            {
                BaseAddress = new Uri(urlService)
            };

            var smsUser = new SmsUserDto();

            smsUser.UserName = userName;

            StringContent content = new StringContent(JsonConvert.SerializeObject(smsUser), Encoding.UTF8, ContentType.Json);

            var checkUserAccessTokenRequest = await client.PostAsync(checkSmsUserEndpoint, content);

            var checkUserAccessTokenResponse = await checkUserAccessTokenRequest.Content.ReadAsStringAsync();

            if (checkUserAccessTokenResponse == "true")
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async Task <bool> CheckUserIsLogged([FromBody] SmsUserDto smsUserDto)
        {
            var smsLogin = _context.SmsLogin.Where(smslogin => smslogin.UserName == smsUserDto.UserName && smslogin.ExpirationTime > DateTime.UtcNow).FirstOrDefault();

            if (smsLogin == null)
            {
                return(false);
            }
            return(true);
        }