示例#1
0
        private static bool SetSession(UserDataFetcher UDF)
        {
            /* Session. unix in file.
             * we will hash it.
             * send it to server.
             * __________________
             * check procedure:
             * if hash matches -> proceed
             * does not match -> invalid session
             */
            if (!InputValidator.ValidateId(UDF.GetId()))
            {
                return(error.SetErrorAndReturnFalse(ErrorCode.USER_NOT_FOUND));
            }
            //-----timestamp
            long unix = DataFetcher.GetServerTimeStamp();

            UserDataPusher.PushSessionFileLoggedIn(unix);
            string hashedUnix = timestampHasher.Hash(unix.ToString(), DataFetcher.GetDeviceIdentifier());

            UserDataPusher.UpdateUserSession(UDF, unix, hashedUnix);
            //System.Windows.Forms.MessageBox.Show($"hashedUnix: {hashedUnix} ({hashedUnix.Length})");

            return(true);

            /*
             * if (UDF.GetCurrentUserTimeStamp().IsTimeStampOlderThan(7 * 24)) //^extension
             *  //user has not been logged in for a whole week
             *  return true;
             * return true;
             */
        }
示例#2
0
        private static bool IsThisTheLastSessionTimestamp(UserDataFetcher UDF, long lastUnix = -1)
        {
            lastUnix = (lastUnix == -1) ? UserDataFetcher.GetLastLoginTimestamp() : lastUnix;
            string hashedUnix = timestampHasher.Hash(lastUnix.ToString(), DataFetcher.GetDeviceIdentifier());

            if (!UDF.IsThisLastLoggedInTimestampHash(hashedUnix))
            {
                return(false);
            }
            return(true);
        }