Exemplo n.º 1
0
        /// <summary>Attempts to authenticate a user using a Steam Encrypted App Ticket.</summary>
        public static void AuthenticateWithSteamEncryptedAppTicket(string encodedTicket,
                                                                   Action <UserProfile> onSuccess,
                                                                   Action <WebRequestError> onError)
        {
            APIClient.RequestSteamAuthentication(encodedTicket, (t) =>
            {
                UserAuthenticationData authData = new UserAuthenticationData()
                {
                    token            = t,
                    wasTokenRejected = false,
                    steamTicket      = encodedTicket,
                    gogTicket        = null,
                };

                UserAuthenticationData.instance = authData;
                UserAccountManagement.FetchUserProfile(onSuccess, onError);
            },
                                                 (e) =>
            {
                UnityEngine.Debug.LogError(
                    $"<b>[mod.io Authentication Steam]</b> Failed with ticket: {encodedTicket}"
                    + $"{System.Environment.NewLine}{e.ToUnityDebugString()}");
                onError(e);
            }
                                                 );
        }
Exemplo n.º 2
0
        // ---------[ UTILITY ]---------
        /// <summary>A wrapper function for setting the UserAuthenticationData.wasTokenRejected to false.</summary>
        public static void MarkAuthTokenRejected()
        {
            UserAuthenticationData data = UserAuthenticationData.instance;

            data.wasTokenRejected           = true;
            UserAuthenticationData.instance = data;
        }
        /// <summary>Loads the UserAuthenticationData from disk.</summary>
        private static void LoadInstance()
        {
            UserAuthenticationData cachedData;

            if (IOUtilities.TryReadJsonObjectFile(FILE_LOCATION, out cachedData))
            {
                UserAuthenticationData.m_instance = cachedData;
            }
        }
Exemplo n.º 4
0
        /// <summary>Stores the oAuthToken and steamTicket and fetches the UserProfile.</summary>
        private static void FetchUserProfile(Action <UserProfile> onSuccess,
                                             Action <WebRequestError> onError)
        {
            APIClient.GetAuthenticatedUser((p) =>
            {
                UserAuthenticationData data = UserAuthenticationData.instance;
                data.userId = p.id;
                UserAuthenticationData.instance = data;

                if (onSuccess != null)
                {
                    onSuccess(p);
                }
            },
                                           onError);
        }
Exemplo n.º 5
0
        /// <summary>Attempts to authenticate a user using an emailed security code.</summary>
        public static void AuthenticateWithSecurityCode(string securityCode,
                                                        Action <UserProfile> onSuccess,
                                                        Action <WebRequestError> onError)
        {
            APIClient.GetOAuthToken(securityCode, (t) =>
            {
                UserAuthenticationData authData = new UserAuthenticationData()
                {
                    token            = t,
                    wasTokenRejected = false,
                    steamTicket      = null,
                    gogTicket        = null,
                };

                UserAuthenticationData.instance = authData;
                UserAccountManagement.FetchUserProfile(onSuccess, onError);
            },
                                    onError);
        }
Exemplo n.º 6
0
        /// <summary>Attempts to authenticate a user using a GOG Encrypted App Ticket.</summary>
        public static void AuthenticateWithGOGEncryptedAppTicket(string encodedTicket,
                                                                 Action <UserProfile> onSuccess,
                                                                 Action <WebRequestError> onError)
        {
            APIClient.RequestGOGAuthentication(encodedTicket, (t) =>
            {
                UserAuthenticationData authData = new UserAuthenticationData()
                {
                    token            = t,
                    wasTokenRejected = false,
                    gogTicket        = encodedTicket,
                    steamTicket      = null,
                };

                UserAuthenticationData.instance = authData;
                UserAccountManagement.FetchUserProfile(onSuccess, onError);
            },
                                               onError);
        }
 /// <summary>Clears the instance and deletes the data on disk.</summary>
 public static void Clear()
 {
     UserAuthenticationData.m_instance = UserAuthenticationData.NONE;
     IOUtilities.DeleteFile(UserAuthenticationData.FILE_LOCATION);
 }
Exemplo n.º 8
0
 // ---------[ SAVE/LOAD ]---------
 /// <summary>Clears the instance and deletes the data on disk.</summary>
 public static void Clear()
 {
     UserAuthenticationData.instance = UserAuthenticationData.NONE;
 }