public async Task <Result <LoginDto> > Login(string email, string password, HttpRequest request)
        {
            var result = await _services.Login(email);

            if (!result.Success)
            {
                return(_result.Create <LoginDto>(false, result.Message, null));
            }

            if (result.Value.Block && DateTime.UtcNow < result.Value.ExpirationBlock)
            {
                return(_result.Create <LoginDto>(false, _errors.Block + " " + result.Value.ExpirationBlock.ToString("s"), null));
            }
            else
            {
                var secret = _crypto.GetStringSha256Hash(email + password + _settings.SecretKey);
                if (result.Value.Password != secret)
                {
                    result.Value.TryCounter++;
                    if (result.Value.TryCounter == 3)
                    {
                        DateTime expire = DateTime.UtcNow.AddSeconds(_settingsTokens.ExpiredTimeInSecondsToUserLocked);
                        result.Value.Block           = true;
                        result.Value.ExpirationBlock = expire;

                        if (_settings.RedisCacheSecurity)
                        {
                            var tokens = await _redisCache.GetSringValue(result.Value.id);

                            if (!String.IsNullOrEmpty(tokens))
                            {
                                var modelRedis = JsonConvert.DeserializeObject <RedisSecurityModel>(tokens);
                                modelRedis.Block = true;

                                var jsonString = JsonConvert.SerializeObject(modelRedis);
                                await _redisCache.SetStringValue(result.Value.id, jsonString);
                            }
                        }
                    }
                    await _services.Update(result.Value);

                    return(_result.Create <LoginDto>(false, _errors.NotAuthorized, null));
                }
                else
                {
                    result.Value.Block      = false;
                    result.Value.TryCounter = 0;
                    await _services.Update(result.Value);

                    if (_settings.RedisCacheSecurity)
                    {
                        var tokens = await _redisCache.GetSringValue(result.Value.id);

                        if (!String.IsNullOrEmpty(tokens))
                        {
                            var modelRedis = JsonConvert.DeserializeObject <RedisSecurityModel>(tokens);
                            modelRedis.Scopes     = result.Value.Scopes;
                            modelRedis.Scopes     = result.Value.Tenants;
                            modelRedis.ValidEmail = result.Value.ValidEmail;
                            modelRedis.Block      = false;

                            var jsonString = JsonConvert.SerializeObject(modelRedis);
                            await _redisCache.SetStringValue(result.Value.id, jsonString);
                        }
                    }
                }
            }

            var dataResult = GetToken(result.Value);

            var login = EndToken(request, _settingsTokens.CookieToken, _settingsSecrets.CookieTokenPath, dataResult.Value);

            return(_result.Create(true, "", login));
        }