Comments (12)
signing massage has expired
This is a mistake of the developers
That's why the user can only be saved for the first 20 seconds
from unity-web3-game-kit.
I am not sure the error you show in the image is related.
Here is some sample code for extending a user to create a custom user. I used this and it worked for me without error:
Sample User extension code:
using Cysharp.Threading.Tasks;
using MoralisUnity;
using MoralisUnity.Platform.Objects;
using MoralisUnity.Platform.Queries;
namespace Assets.Scripts
{
/// <summary>
/// Create your custom user object derived from MoralisUser.
/// Here I created a user that holds an access level and
/// address properties.
/// </summary>
public class MyCustomUser : MoralisUser
{
public int AccessLevel { get; set; }
public string Street { get; set; }
public string City { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
public string State { get; set; }
public MyCustomUser() { }
public MyCustomUser(MoralisUser baseUser)
{
base.accounts = baseUser.accounts;
base.ACL = baseUser.ACL;
base.authData = baseUser.authData;
base.createdAt = baseUser.createdAt;
base.email = baseUser.email;
base.ethAddress = baseUser.ethAddress;
base.objectId = baseUser.objectId;
base.sessionToken = baseUser.sessionToken;
base.updatedAt = baseUser.updatedAt;
base.username = baseUser.username;
// Necessary step to make sure the customer user is saved to
// the _User table and not a new table.
base.ClassName = baseUser.ClassName;
}
}
/// <summary>
/// The whole purpose of this class is to trick the MoralisQuery to
/// target the "_User" table
/// </summary>
internal class _User : MyCustomUser { }
/// <summary>
/// This class provides some examples showing how to create a user and
/// then load it at need.
/// </summary>
public class CustomUserServiceExample
{
public static async UniTask<MyCustomUser> CreateUser(MoralisUser user, int accessLevel, string street, string city, string state, string postalCode, string country)
{
MyCustomUser newUser = new MyCustomUser(user);
newUser.City = city;
newUser.State = state;
newUser.PostalCode = postalCode;
newUser.Country = country;
newUser.Street = street;
newUser.AccessLevel = accessLevel;
await newUser.SaveAsync();
return newUser;
}
/// <summary>
/// Loads a custom user object using the normal MoralisUser
/// as a reference.
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public static async UniTask<MyCustomUser> LoadFromUser(MoralisUser user)
{
return await LoadFromUser(user.objectId);
}
/// <summary>
/// Loads a customer user using an objectId
/// </summary>
/// <param name="objectId"></param>
/// <returns></returns>
public static async UniTask<MyCustomUser> LoadFromUser(string objectId)
{
// Query using the _User object so query is against the "_User" table.
MoralisQuery<_User> q = await Moralis.Query<_User>();
_User user = await q.WhereEqualTo("objectId", objectId).FirstOrDefaultAsync();
// Since _User is derived from MyCustomUser you can just return it
// and it will be returned as a MyCustomUser.
return user;
}
}
}
Here is sample code showing how I used the user extension:
internal class Testor
{
public async static void TestStuff()
{
await CreateCustomUserTest();
await GetCustomUserTest();
}
private static async UniTask CreateCustomUserTest()
{
MoralisUser user = await Moralis.GetUserAsync();
await Assets.Scripts.CustomUserServiceExample.CreateUser(user, 4321, "555 My Street", "MyCity", "FL", "33809", "US");
}
private static async UniTask GetCustomUserTest()
{
MoralisUser user = await Moralis.GetUserAsync();
Assets.Scripts.MyCustomUser myUser = await Assets.Scripts.CustomUserServiceExample.LoadFromUser(user.objectId);
Debug.Log($"Street: {myUser.Street}, City: {myUser.City}, State: {myUser.State}, Zip: {myUser.PostalCode}");
}
}
```
from unity-web3-game-kit.
I am not sure the error you show in the image is related.
Here is some sample code for extending a user to create a custom user. I used this and it worked for me without error:
Sample User extension code:
using Cysharp.Threading.Tasks; using MoralisUnity; using MoralisUnity.Platform.Objects; using MoralisUnity.Platform.Queries; namespace Assets.Scripts { /// <summary> /// Create your custom user object derived from MoralisUser. /// Here I created a user that holds an access level and /// address properties. /// </summary> public class MyCustomUser : MoralisUser { public int AccessLevel { get; set; } public string Street { get; set; } public string City { get; set; } public string PostalCode { get; set; } public string Country { get; set; } public string State { get; set; } public MyCustomUser() { } public MyCustomUser(MoralisUser baseUser) { base.accounts = baseUser.accounts; base.ACL = baseUser.ACL; base.authData = baseUser.authData; base.createdAt = baseUser.createdAt; base.email = baseUser.email; base.ethAddress = baseUser.ethAddress; base.objectId = baseUser.objectId; base.sessionToken = baseUser.sessionToken; base.updatedAt = baseUser.updatedAt; base.username = baseUser.username; // Necessary step to make sure the customer user is saved to // the _User table and not a new table. base.ClassName = baseUser.ClassName; } } /// <summary> /// The whole purpose of this class is to trick the MoralisQuery to /// target the "_User" table /// </summary> internal class _User : MyCustomUser { } /// <summary> /// This class provides some examples showing how to create a user and /// then load it at need. /// </summary> public class CustomUserServiceExample { public static async UniTask<MyCustomUser> CreateUser(MoralisUser user, int accessLevel, string street, string city, string state, string postalCode, string country) { MyCustomUser newUser = new MyCustomUser(user); newUser.City = city; newUser.State = state; newUser.PostalCode = postalCode; newUser.Country = country; newUser.Street = street; newUser.AccessLevel = accessLevel; await newUser.SaveAsync(); return newUser; } /// <summary> /// Loads a custom user object using the normal MoralisUser /// as a reference. /// </summary> /// <param name="user"></param> /// <returns></returns> public static async UniTask<MyCustomUser> LoadFromUser(MoralisUser user) { return await LoadFromUser(user.objectId); } /// <summary> /// Loads a customer user using an objectId /// </summary> /// <param name="objectId"></param> /// <returns></returns> public static async UniTask<MyCustomUser> LoadFromUser(string objectId) { // Query using the _User object so query is against the "_User" table. MoralisQuery<_User> q = await Moralis.Query<_User>(); _User user = await q.WhereEqualTo("objectId", objectId).FirstOrDefaultAsync(); // Since _User is derived from MyCustomUser you can just return it // and it will be returned as a MyCustomUser. return user; } } }
Here is sample code showing how I used the user extension:
internal class Testor { public async static void TestStuff() { await CreateCustomUserTest(); await GetCustomUserTest(); } private static async UniTask CreateCustomUserTest() { MoralisUser user = await Moralis.GetUserAsync(); await Assets.Scripts.CustomUserServiceExample.CreateUser(user, 4321, "555 My Street", "MyCity", "FL", "33809", "US"); } private static async UniTask GetCustomUserTest() { MoralisUser user = await Moralis.GetUserAsync(); Assets.Scripts.MyCustomUser myUser = await Assets.Scripts.CustomUserServiceExample.LoadFromUser(user.objectId); Debug.Log($"Street: {myUser.Street}, City: {myUser.City}, State: {myUser.State}, Zip: {myUser.PostalCode}"); } } ```
This only works for 20 seconds
from unity-web3-game-kit.
I need to be able to save the user at any time, not in the first 20 seconds.
from unity-web3-game-kit.
This issue is duplicated by #119 and #118
from unity-web3-game-kit.
Oh Really? Then why are you silent and doing nothing?
It would be better if you wrote a solution than such nonsense
from unity-web3-game-kit.
I am not sure the error you show in the image is related.
Here is some sample code for extending a user to create a custom user. I used this and it worked for me without error:
Sample User extension code:
using Cysharp.Threading.Tasks; using MoralisUnity; using MoralisUnity.Platform.Objects; using MoralisUnity.Platform.Queries; namespace Assets.Scripts { /// <summary> /// Create your custom user object derived from MoralisUser. /// Here I created a user that holds an access level and /// address properties. /// </summary> public class MyCustomUser : MoralisUser { public int AccessLevel { get; set; } public string Street { get; set; } public string City { get; set; } public string PostalCode { get; set; } public string Country { get; set; } public string State { get; set; } public MyCustomUser() { } public MyCustomUser(MoralisUser baseUser) { base.accounts = baseUser.accounts; base.ACL = baseUser.ACL; base.authData = baseUser.authData; base.createdAt = baseUser.createdAt; base.email = baseUser.email; base.ethAddress = baseUser.ethAddress; base.objectId = baseUser.objectId; base.sessionToken = baseUser.sessionToken; base.updatedAt = baseUser.updatedAt; base.username = baseUser.username; // Necessary step to make sure the customer user is saved to // the _User table and not a new table. base.ClassName = baseUser.ClassName; } } /// <summary> /// The whole purpose of this class is to trick the MoralisQuery to /// target the "_User" table /// </summary> internal class _User : MyCustomUser { } /// <summary> /// This class provides some examples showing how to create a user and /// then load it at need. /// </summary> public class CustomUserServiceExample { public static async UniTask<MyCustomUser> CreateUser(MoralisUser user, int accessLevel, string street, string city, string state, string postalCode, string country) { MyCustomUser newUser = new MyCustomUser(user); newUser.City = city; newUser.State = state; newUser.PostalCode = postalCode; newUser.Country = country; newUser.Street = street; newUser.AccessLevel = accessLevel; await newUser.SaveAsync(); return newUser; } /// <summary> /// Loads a custom user object using the normal MoralisUser /// as a reference. /// </summary> /// <param name="user"></param> /// <returns></returns> public static async UniTask<MyCustomUser> LoadFromUser(MoralisUser user) { return await LoadFromUser(user.objectId); } /// <summary> /// Loads a customer user using an objectId /// </summary> /// <param name="objectId"></param> /// <returns></returns> public static async UniTask<MyCustomUser> LoadFromUser(string objectId) { // Query using the _User object so query is against the "_User" table. MoralisQuery<_User> q = await Moralis.Query<_User>(); _User user = await q.WhereEqualTo("objectId", objectId).FirstOrDefaultAsync(); // Since _User is derived from MyCustomUser you can just return it // and it will be returned as a MyCustomUser. return user; } } }
Here is sample code showing how I used the user extension:
internal class Testor { public async static void TestStuff() { await CreateCustomUserTest(); await GetCustomUserTest(); } private static async UniTask CreateCustomUserTest() { MoralisUser user = await Moralis.GetUserAsync(); await Assets.Scripts.CustomUserServiceExample.CreateUser(user, 4321, "555 My Street", "MyCity", "FL", "33809", "US"); } private static async UniTask GetCustomUserTest() { MoralisUser user = await Moralis.GetUserAsync(); Assets.Scripts.MyCustomUser myUser = await Assets.Scripts.CustomUserServiceExample.LoadFromUser(user.objectId); Debug.Log($"Street: {myUser.Street}, City: {myUser.City}, State: {myUser.State}, Zip: {myUser.PostalCode}"); } } ```
Where are you?
from unity-web3-game-kit.
Looking further ...
from unity-web3-game-kit.
There was a security update on the backend that now re-validates the signature everytime it is posted. I will need to add a patch for this in the Unity SDK.
For now to get past the issue, before you call user.SaveAsync()
, clear the authData array. For example:
user.authData.Clear();
await user.SaveAsync();
from unity-web3-game-kit.
There was a security update on the backend that now re-validates the signature everytime it is posted. I will need to add a patch for this in the Unity SDK.
For now to get past the issue, before you call
user.SaveAsync()
, clear the authData array. For example:user.authData.Clear(); await user.SaveAsync();
Thanks, it works.
Dear developers, please take a closer look at the problems. For a whole month you ignored the problem and said that everything was working
from unity-web3-game-kit.
Re-open as I want to incorporate a solution into the SDK ...
from unity-web3-game-kit.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from unity-web3-game-kit.
Related Issues (20)
- [BUG] Unity WEBGL problem with multiple Live queries. HOT 11
- 'Strip engine code' higher than low (player settings) causes important constructors to be stripped from MoralisUser HOT 7
- Moralis conflicts the photon plugin, websocket.jslib conflicts with the one in photon websocket jslib HOT 3
- WalletConnect Session Reconnection (pls) HOT 3
- unity webgl minting not work HOT 2
- Can't update MoralisUser fields after few seconds HOT 3
- "code":206,"error":"Insufficient auth." HOT 8
- NFTs no longer showing, using cloud, did not touch app in about a month HOT 1
- Unity webGL - Execute Contract Function - Minting Issue (HexBigInteger - Invalid Big Number Returned (Error: invalid BigNumber string)) HOT 6
- Web3 Game Kit Package v1.2.7 missing .unitypackage HOT 1
- WalletConnect has been destroyed HOT 3
- Error: HTTP/1.1 403 Forbidden {"error":"unauthorized"} HOT 22
- ExecuteContractFunction gives transaction error HOT 4
- v1.2.7 Unauthorized Problem HOT 5
- v1.2.10 WebGL Build not Connecting HOT 9
- Paybale function showing JSON-RPC error on Metamask HOT 3
- SDK No longer works with Moralis V2 or Self Hosted V1 HOT 1
- Not Compatible with WalletConnect v2 HOT 1
- Not compatible with WalletConnect v2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unity-web3-game-kit.