private async Task UpdateSyncTokenAsync() { string sig = MD.Encrypt(this.userId + AppToken); var response = await this.service.GetToken(this.userId, sig); if (response.HasError) { this.OnSynchronizationFailed(response.Error); } else { this.tokenTimestamp = DateTime.Now.Ticks; this.token = response.Data; this.key = MD.Encrypt(MD.Encrypt(this.CryptoService.Decrypt(this.password)) + AppToken + this.token); } }
private async Task <string> GetUserId() { if (string.IsNullOrEmpty(this.email)) { this.OnSynchronizationFailed(ToodleDoResources.ToodleDo_EmptyUsername); return(null); } if (this.password == null || this.password.Length == 0) { this.OnSynchronizationFailed(ToodleDoResources.ToodleDo_EmptyPassword); return(null); } string decryptedPassword = this.CryptoService.Decrypt(this.password); if (string.IsNullOrEmpty(decryptedPassword)) { // password exist but cannot be decrypted (because device changed for example) // remove this password and signal is it empty this.Workbook.Settings.SetValue <byte[]>(ToodleDoSettings.ToodleDoPassword, null); this.OnSynchronizationFailed(ToodleDoResources.ToodleDo_EmptyPassword); return(null); } if (string.IsNullOrEmpty(this.userId)) { string sig = MD.Encrypt(this.email + AppToken); var response = await this.service.GetUserId(sig, this.email, this.CryptoService.Decrypt(this.password)); if (response.HasError) { this.OnSynchronizationFailed(response.Error); } else { return(response.Data); } } return(this.userId); }