Exemplo n.º 1
0
        public (bool ValidationResult, string ValidationMessage) ValidateGetCode(string phoneNumber)
        {
            if (string.IsNullOrWhiteSpace(phoneNumber))
            {
                return(false, ErrorDictionary.GetErrorMessage(6, _culture));
            }
            else if (!Regex.Match(phoneNumber, RegexTemplates.PhoneTemplate).Success)
            {
                return(false, ErrorDictionary.GetErrorMessage(6, _culture));
            }
            var person = _authorizationRepository.GetPerson(phoneNumber).Result;

            if (person != null && person.TemporaryCodeTime.HasValue)
            {
                var timeDifference = (DateTime.UtcNow - person.TemporaryCodeTime.Value).TotalSeconds;
                if (timeDifference < 30)
                {
                    return(false, ErrorDictionary.GetErrorMessage(45, _culture));
                }
            }
            return(true, string.Empty);
        }
Exemplo n.º 2
0
        public async Task <AuthorizationPersonModel> GetPerson(string phoneNumber, CancellationToken cancellationToken = default)
        {
            var dalPerson = await _authorizationRepository.GetPerson(phoneNumber, cancellationToken);

            return(ConvertPersonModel(dalPerson));
        }