Beispiel #1
0
    private void Awake()
    {
        _usageTrackingManager.AcceptableBackgroundTime = _acceptableBackgroundTime;

        var             tokensPath    = Path.Combine(Application.persistentDataPath, TOKENS_STORAGE_FILENAME);
        UserDataStorage tokensStorage = BsonDataManager.ReadData <UserDataStorage>(tokensPath);

        if (tokensStorage == null)
        {
            _login.Open();
            return;
        }

        NetworkManager.Instance.UserDataStorage = tokensStorage;
        NetworkManager.Instance.Authorization(
            (e, r) =>
        {
            _login.Open();
        },
            () =>
        {
            _choice.Open();
            UsageTrackingManager.Instance.GrabReports();
        });
    }
        public async Task <IActionResult> Update(
            [FromRoute] Guid id,
            [FromForm] DatasetNomination nomination,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (id != nomination.Id)
            {
                throw new InvalidOperationException("Nomination id is not valid.");
            }

            var validationResult = ValidationService.IsDatasetNominationValidForUpdate(nomination);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult));
            }

            var nominationId = await UserDataStorage.UpdateDatasetNominationAsync(this.User, nomination, cancellationToken).ConfigureAwait(false);

            if (nominationId.HasValue)
            {
                return(this.Ok(nominationId));
            }

            return(this.NotFound());
        }
Beispiel #3
0
        public static void ClearAllUserData()
        {
            UserDataStorage.WriteFileCallback onClear = (success) =>
            {
                LocalUser.instance = new LocalUser();
                LocalUser.isLoaded = true;

                if (success)
                {
                    Debug.Log("[mod.io] User Data Cleared.");
                }
                else
                {
                    Debug.Log("[mod.io] Failed to clear User Data.");
                }
            };

            if (!UserDataStorage.isInitialized)
            {
                UserDataStorage.InitializeForUser(null, () => UserDataStorage.ClearAllData(onClear));
            }
            else
            {
                UserDataStorage.ClearAllData(onClear);
            }
        }
Beispiel #4
0
        public async Task <User> validateUserLogin(string loginId, string password)
        {
            UserDataStorage userDataStorage = new UserDataStorage(_iconfiguration, _unicastEmailSender);

            try
            {
                var result = await userDataStorage.ValidateUserLogin(loginId, password);

                if (result == null)
                {
                    return(result);
                }
                else
                {
                    TokenService tokenService = new TokenService();
                    string       authtoken    = tokenService.GetToken(/*pass role*/);
                    result.authToken = authtoken;
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 static UserAccounts()
 {
     if (UserDataStorage.SaveExists(accountsFile))
     {
         _accounts = UserDataStorage.LoadUserAccounts(accountsFile).ToList();
     }
     else
     {
         _accounts = new List <UserAccount>();
         SaveAccounts();
     }
 }
Beispiel #6
0
 private async Task UpdateNominationStatusToError()
 {
     try
     {
         await UserDataStorage
         .UpdateNominationStatus(Options.NominationId, NominationStatus.Error, null, CancellationToken.None);
     }
     catch (Exception ex)
     {
         Log.BatchError(ex);
     }
 }
        public async Task <IActionResult> GetById([FromRoute] Guid id, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            var result = await UserDataStorage.GetByIdAsync(id, cancellationToken).ConfigureAwait(false);

            if (result == null)
            {
                return(this.NotFound());
            }

            return(this.Ok(result));
        }
        public async Task <IActionResult> GetOtherLicenseFile([FromRoute] Guid id, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var otherLicenseFile = await UserDataStorage.GetOtherLicenseFileAsync(id, cancellationToken);

            if (otherLicenseFile == null)
            {
                return(NotFound());
            }

            return(File(otherLicenseFile.Content, otherLicenseFile.ContentType, otherLicenseFile.FileName));
        }
Beispiel #9
0
        private void Start()
        {
            _menuScreenView.Hide();
            _levelScreenView.Hide();

            _userDataStorage       = new UserDataStorage();
            _appPersistenceService = new AppPersistenceService(Path.Combine(Application.persistentDataPath, "local"));

            SetupUserPersistence(_userDataStorage);
            SetupUserServices(_userDataStorage);
            SetupGameServices();
            Resolve <IGameFlowService>().ChangeState();
        }
Beispiel #10
0
        public async Task <string> AddUser(RegisterUser registerUser)
        {
            UserDataStorage userDataStorage = new UserDataStorage(_iconfiguration, _unicastEmailSender);

            try
            {
                var result = await userDataStorage.AddUser(registerUser);

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #11
0
        public async Task <string> ChangePassword(string loginId, string newPassword, string oldpassword)
        {
            UserDataStorage userDataStorage = new UserDataStorage(_iconfiguration, _unicastEmailSender);

            try
            {
                var result = await userDataStorage.ChangePassword(loginId, newPassword, oldpassword);

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #12
0
        public async Task <string> ForgetPassword(string loginid)
        {
            UserDataStorage userDataStorage = new UserDataStorage(_iconfiguration, _unicastEmailSender);

            try
            {
                var result = await userDataStorage.ForgetPassword(loginid);

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #13
0
        public static void ClearAllUserData()
        {
            UserDataStorage.ClearActiveUserData((success) =>
            {
                LocalUser.instance = new LocalUser();
                LocalUser.isLoaded = true;

                if (success)
                {
                    Debug.Log("[mod.io] User Data Cleared.");
                }
                else
                {
                    Debug.Log("[mod.io] Failed to clear User Data.");
                }
            });
        }
        public async Task <IActionResult> ImportDatasetFromStorage(
            [FromRoute] Guid id,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var(found, name) = await UserDataStorage.UpdateNominationStatusAndReturnName(id, NominationStatus.Importing, User, cancellationToken);

            if (!found)
            {
                return(NotFound());
            }

            await AppJobs.StartDatasetImportJob(id, name);

            return(Ok());
        }
        public async Task <IActionResult> DatasetContainer([FromRoute] Guid id, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var nomination = await UserDataStorage.GetByIdAsync(id, cancellationToken).ConfigureAwait(false);

            if (nomination == null)
            {
                return(NotFound());
            }

            var storage = new DatasetStorage
            {
                Id          = nomination.Id,
                AccountName = SasTokenService.DefaultDatasetStorageAccount(),
                DatasetName = nomination.Name,
            };
            await SasTokenService.FindUniqueDatasetContainerName(storage).ConfigureAwait(false);

            return(Ok(storage));
        }
        public async Task <IActionResult> CreateStorage(
            [FromRoute] Guid id,
            [FromBody] DatasetStorage storage,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (id != storage.Id)
            {
                throw new InvalidOperationException("Nomination id is not valid.");
            }

            var status = await UserDataStorage.CreateDatasetStorageAsync(storage, this.User, cancellationToken).ConfigureAwait(false);

            if (status == null)
            {
                return(NotFound());
            }

            return(Ok());
        }
        public async Task <IActionResult> Reject(
            [FromRoute] Guid id,
            [FromBody] DatasetNomination nomination,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (id != nomination.Id)
            {
                throw new InvalidOperationException("Nomination id is not valid.");
            }

            // intentionally no validation for Rejecting a nomination

            bool found = await UserDataStorage.RejectNominationAsync(id, this.User, cancellationToken).ConfigureAwait(false);

            if (!found)
            {
                return(this.NotFound());
            }

            return(Ok());
        }
Beispiel #18
0
        private async Task <(DatasetNomination nomination, DatasetImportProperties storage)> LoadNomination(CancellationToken cancellationToken)
        {
            var nominationId = Options.NominationId;

            var nomination = await UserDataStorage.GetByIdAsync(nominationId, cancellationToken);

            if (nomination == null)
            {
                throw new InvalidOperationException("Nomination Id was not found.");
            }

            Log.Add($"Name: {nomination.Name}");

            var storage =
                await UserDataStorage.GetDatasetImportPropertiesForNomination(nominationId, cancellationToken);

            if (storage == null)
            {
                throw new InvalidOperationException("Nomination storage details were not found.");
            }

            return(nomination, storage);
        }
        public async Task <IActionResult> CreateApproved(
            [FromForm] DatasetNomination nomination,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var validationResult = ValidationService.IsDatasetNominationValidForApproval(nomination);

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult));
            }

            nomination.NominationStatus = NominationStatus.Approved;

            var nominationId = await UserDataStorage.CreateDatasetNominationAsync(this.User, nomination, cancellationToken).ConfigureAwait(false);

            if (nominationId.HasValue)
            {
                return(this.Ok(nominationId));
            }

            return(this.NotFound());
        }
Beispiel #20
0
 private void SetupUserPersistence(UserDataStorage userDataStorage)
 {
     _appPersistenceService.Register(userDataStorage.Results, "results");
     _appPersistenceService.ApplyFromSaveFile();
 }
 public static void SaveAccounts()
 {
     UserDataStorage.SaveUserAccounts(_accounts, accountsFile);
 }
Beispiel #22
0
 private async Task UpdateNominationStatusToCompleted(CancellationToken cancellationToken)
 {
     await UserDataStorage
     .UpdateNominationStatus(Options.NominationId, NominationStatus.Complete, null, cancellationToken);
 }
Beispiel #23
0
 private void SetupUserServices(UserDataStorage userDataStorage)
 {
     _dependencies.Add(typeof(IResultService), new UserResultService(userDataStorage.Results));
 }
Beispiel #24
0
 public static void SaveChannels()
 {
     UserDataStorage.SaveChannels(channels, configFolder + "/" + configFile);
 }