public async Task LoginWithAuthDataWithUnionId() { string uuid = Guid.NewGuid().ToString(); Dictionary <string, object> authData = new Dictionary <string, object> { { "expires_in", 7200 }, { "openid", uuid }, { "access_token", uuid } }; string unionId = Guid.NewGuid().ToString(); LCUserAuthDataLoginOption option = new LCUserAuthDataLoginOption(); option.AsMainAccount = true; LCUser currentUser = await LCUser.LoginWithAuthDataAndUnionId(authData, "weixin_app", unionId, option : option); TestContext.WriteLine(currentUser.SessionToken); Assert.NotNull(currentUser.SessionToken); string userId = currentUser.ObjectId; TestContext.WriteLine($"userId: {userId}"); TestContext.WriteLine(currentUser.AuthData); await LCUser.Logout(); currentUser = await LCUser.GetCurrent(); Assert.IsNull(currentUser); currentUser = await LCUser.LoginWithAuthDataAndUnionId(authData, "weixin_mini_app", unionId, option : option); TestContext.WriteLine(currentUser.SessionToken); Assert.NotNull(currentUser.SessionToken); Assert.AreEqual(currentUser.ObjectId, userId); TestContext.WriteLine(currentUser.AuthData); }
public async Task LoginWithAuthData() { string uuid = Guid.NewGuid().ToString(); Dictionary <string, object> authData = new Dictionary <string, object> { { "expires_in", 7200 }, { "openid", uuid }, { "access_token", uuid } }; LCUser currentUser = await LCUser.LoginWithAuthData(authData, "weixin"); TestContext.WriteLine(currentUser.SessionToken); Assert.NotNull(currentUser.SessionToken); string userId = currentUser.ObjectId; TestContext.WriteLine($"userId: {userId}"); TestContext.WriteLine(currentUser.AuthData); await LCUser.Logout(); currentUser = await LCUser.GetCurrent(); Assert.IsNull(currentUser); currentUser = await LCUser.LoginWithAuthData(authData, "weixin"); TestContext.WriteLine(currentUser.SessionToken); Assert.NotNull(currentUser.SessionToken); Assert.AreEqual(currentUser.ObjectId, userId); TestContext.WriteLine(currentUser.AuthData); }
public async Task UserReadAndWrite() { await LCUser.Login("hello", "world"); LCObject account = new LCObject("Account"); LCUser currentUser = await LCUser.GetCurrent(); LCACL acl = LCACL.CreateWithOwner(currentUser); account.ACL = acl; account["balance"] = 512; await account.Save(); Assert.IsTrue(acl.GetUserReadAccess(currentUser)); Assert.IsTrue(acl.GetUserWriteAccess(currentUser)); LCQuery <LCObject> query = new LCQuery <LCObject>("Account"); LCObject result = await query.Get(account.ObjectId); TestContext.WriteLine(result.ObjectId); Assert.NotNull(result.ObjectId); await LCUser.Logout(); result = await query.Get(account.ObjectId); Assert.IsNull(result); }
public async Task UserReadAndWrite() { await LCUser.Login(TestPhone, TestPhone); account = new Account(); LCUser currentUser = await LCUser.GetCurrent(); account.ACL = LCACL.CreateWithOwner(currentUser); account.Balance = 512; await account.Save(); Assert.IsTrue(account.ACL.GetUserReadAccess(currentUser)); Assert.IsTrue(account.ACL.GetUserWriteAccess(currentUser)); LCQuery <LCObject> query = new LCQuery <LCObject>("Account"); LCObject result = await query.Get(account.ObjectId); TestContext.WriteLine(result.ObjectId); Assert.NotNull(result.ObjectId); await LCUser.Logout(); try { await query.Get(account.ObjectId); } catch (LCException e) { Assert.AreEqual(e.Code, 403); } }
public async Task LoginBySessionToken() { await LCUser.Logout(); string sessionToken = "luo2fpl4qij2050e7enqfz173"; await LCUser.BecomeWithSessionToken(sessionToken); LCUser current = await LCUser.GetCurrent(); Assert.NotNull(current.ObjectId); }
public async Task Logout() { try { await LCUser.Logout(); LCUtils.RemoveLocalUser(); await IMClient.Close(); User = null; IMClient = null; } catch (LCException e) { LCUtils.LogException(e); } }