Exemplo n.º 1
0
        public bool IsBearerValid(Microsoft.AspNetCore.Http.HttpRequest request, string urlSafeName)
        {
            if ((Request.Headers["Authorization"].ToString() ?? "").Trim().Length <= 0)
            {
                return(false);
            }

            var bearer = Request.Headers["Authorization"]
                         .ToString().Replace("Bearer ", "");
            var channelUser = _updateStatusContent
                              .GetChannelUserIdByUrlSafeName(urlSafeName, true);

            return(channelUser.Bearer == bearer);
        }
Exemplo n.º 2
0
        public IActionResult Index(DateDto dto)
        {
            var date         = dto.GetDateTime();
            var urlSafeName  = dto.Name;
            var relativeDays = dto.GetRelativeDays(date);

            var tommorow  = date.AddDays(1);
            var yesterday = date.AddDays(-1);

            var allChannelUsers = _updateStatusContent.GetAllChannelUsers()
                                  .Where(p => p.IsVisible && p.IsAccessible).ToList();

            if (!allChannelUsers.Any())
            {
                return(BadRequest("Database connection successful; Please add a ChannelUser first to continue; You need to restart the application"));
            }

            // Show default page
            if (string.IsNullOrEmpty(urlSafeName))
            {
                var find = allChannelUsers.Find(x => x.NameUrlSafe.Contains("tafelvoetbal"));

                if (find != null)
                {
                    urlSafeName = find.NameUrlSafe;
                }
                else
                {
                    var selectItemUrlSafe = allChannelUsers.Single(p => p.NameUrlSafe.Length >= 1).NameUrlSafe;
                    if (selectItemUrlSafe != null)
                    {
                        urlSafeName = selectItemUrlSafe;
                    }
                }
            }

            var channelUserObject = _updateStatusContent.GetChannelUserIdByUrlSafeName(urlSafeName, false);

            if (channelUserObject == null)
            {
                return(NotFound("not found"));
            }

            var model = new HomeViewModel
            {
                List         = allChannelUsers,
                Name         = channelUserObject.Name,
                NameId       = channelUserObject.NameId,
                NameUrlSafe  = channelUserObject.NameUrlSafe,
                RelativeDate = relativeDays,
                Today        = date.Year + "-" + dto.LeadingZero(date.Month) + "-" + dto.LeadingZero(date.Day),
                Tomorrow     = tommorow.Year + "-" + dto.LeadingZero(tommorow.Month) + "-" + dto.LeadingZero(tommorow.Day),
                Yesterday    = yesterday.Year + "-" + dto.LeadingZero(yesterday.Month) + "-" + dto.LeadingZero(yesterday.Day),
                Day          = dto.GetDateTime()
            };



            if (model.RelativeDate == 0)
            {
                var isFreeStatus = _updateStatusContent.IsFree(channelUserObject.NameId);
                model.IsFree = isFreeStatus.IsFree;
                model.IsFreeLatestUtcString         = isFreeStatus.DateTimeUtcString;
                model.IsFreeLatestAmsterdamDateTime = dto.UtcDateTimeToAmsterdamDateTime(isFreeStatus.DateTime);
                return(View("Live", model));
            }

            return(View("Archive", model));
        }