Exemplo n.º 1
0
        public ActionResult Index()
        {
            var           existingUser  = ChatHelper.GetChatUserFromCookie(this.Request);
            ChatViewModel chatViewModel = null;

            if (existingUser != null)
            {
                if (!ChatHub.IsUserRegistered(existingUser))
                {
                    // cookie is invalid
                    ChatHelper.RemoveCookie(this.Response);
                    return(this.RedirectToAction("Index"));
                }

                // in this case the authentication cookie is valid and we must render the chat
                chatViewModel = new ChatViewModel()
                {
                    IsUserAuthenticated = true,
                    UserId   = existingUser.Id,
                    UserName = existingUser.Name,
                    UserProfilePictureUrl = existingUser.ProfilePictureUrl
                };
            }

            return(this.View(chatViewModel));
        }