public async Task DoLogin(string email, string password) { try { Username = email; using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create()) { byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(email); byte[] hashBytes = md5.ComputeHash(inputBytes); // Convert the byte array to hexadecimal string StringBuilder sb = new StringBuilder(); for (int i = 0; i < hashBytes.Length; i++) { sb.Append(hashBytes[i].ToString("X2")); } Gravatar = sb.ToString().ToLower(); } app = Realms.Sync.App.Create("opkanban-lymqs"); user = await app.LogInAsync(Realms.Sync.Credentials.EmailPassword(email, password)); partition = $"user={ user.Id }"; config = new Realms.Sync.SyncConfiguration(partition, user); realm = await Realm.GetInstanceAsync(config); IsLoggedIn = true; LoginFailed = false; } catch (Exception e) { IsLoggedIn = false; LoginFailed = true; } NotifyStateChanged(); }
async Task ConnectToRealm() { IsBusy = true; var ip = "13.64.233.2"; var credentials = Realms.Sync.Credentials.UsernamePassword("*****@*****.**", "123", false); var authUrl = new Uri($"http://{ip}:9080"); var user = await Realms.Sync.User.LoginAsync(credentials, authUrl); var config = new Realms.Sync.SyncConfiguration(user, new Uri($"realm://{ip}:9080/~/journal")); _realm = Realm.GetInstance(config); Entries = _realm.All <JournalEntry>(); OnPropertyChanged(nameof(Entries)); }