Beispiel #1
0
        private void server_ValidateSession(object sender, ValidateSessionEventArgs<WebHookContext> eventArgs)
        {
            var context = eventArgs.Context;

            if (context == null)
            {
                throw new Exception("WebTransmission Context is null.");
            }

            var session = context.Database.Sessions.GetWebHookSession(eventArgs.SessionKey);
            if (session == null)
            {
                //session does not exist.
                eventArgs.IsValid = false;
                return;
            }

            //TODO: IP address checking?

            if (session.Computer.Equals(context.Computer))
            {
                context.Session = session; //TODO: why does WebCommunicator need to know the SessionRecord?
                eventArgs.IsValid = true;
                return;
            }

            eventArgs.IsValid = false;
        }
Beispiel #2
0
        static void server_ValidateSession(object sender, ValidateSessionEventArgs<MyContext> eventArgs)
        {
            if (!users.Contains(eventArgs.Context.User))
            {
                eventArgs.IsValid = false;
                return;
            }

            if (!userSessions.ContainsKey(eventArgs.Context.User))
            {
                eventArgs.IsValid = false;
                return;
            }

            eventArgs.IsValid = userSessions[eventArgs.Context.User].Equals(eventArgs.SessionKey);
        }