diff --git a/Assets/FirebaseWebGL/Examples/Auth/AuthExampleHandler.cs b/Assets/FirebaseWebGL/Examples/Auth/AuthExampleHandler.cs
index 5700f35..6084112 100644
--- a/Assets/FirebaseWebGL/Examples/Auth/AuthExampleHandler.cs
+++ b/Assets/FirebaseWebGL/Examples/Auth/AuthExampleHandler.cs
@@ -39,7 +39,7 @@ public void SignInWithFacebook() =>
public void DisplayUserInfo(string user)
{
var parsedUser = StringSerializationAPI.Deserialize(typeof(FirebaseUser), user) as FirebaseUser;
- DisplayData($"Email: {parsedUser.email}, UserId: {parsedUser.uid}, EmailVerified: {parsedUser.isEmailVerified}");
+ DisplayData($"Email: {parsedUser.email}, UserId: {parsedUser.uid}, EmailVerified: {parsedUser.emailVerified}");
}
public void DisplayData(string data)
diff --git a/Assets/FirebaseWebGL/Plugins/firebaseauth.jslib b/Assets/FirebaseWebGL/Plugins/firebaseauth.jslib
index e6d0974..b0dc3af 100644
--- a/Assets/FirebaseWebGL/Plugins/firebaseauth.jslib
+++ b/Assets/FirebaseWebGL/Plugins/firebaseauth.jslib
@@ -88,6 +88,59 @@ mergeInto(LibraryManager.library, {
window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
});
+ } catch (error) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
+ },
+
+ SendEmailVerification: function(objectName, callback, fallback){
+ var parsedObjectName = UTF8ToString(objectName);
+ var parsedCallback = UTF8ToString(callback);
+ var parsedFallback = UTF8ToString(fallback);
+
+ try {
+ if(!firebase.auth().currentUser.emailVerified){
+ firebase.auth().currentUser.sendEmailVerification().then(function (unused) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedCallback, "Success: SendEmailVerification");
+ }).catch(function (error) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
+ });
+ }
+ } catch (error) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
+ }
+ },
+
+ SendPasswordResetEmail: function (email, objectName, callback, fallback) {
+ var parsedEmail = UTF8ToString(email);
+ var parsedObjectName = UTF8ToString(objectName);
+ var parsedCallback = UTF8ToString(callback);
+ var parsedFallback = UTF8ToString(fallback);
+
+ try {
+
+ firebase.auth().sendPasswordResetEmail(parsedEmail).then(function (unused) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedCallback, "Success: SendPasswordResetEmail for " + parsedEmail);
+ }).catch(function (error) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
+ });
+
+ } catch (error) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
+ }
+ },
+
+ SignOut: function(objectName, callback, fallback){
+ var parsedObjectName = UTF8ToString(objectName);
+ var parsedCallback = UTF8ToString(callback);
+ var parsedFallback = UTF8ToString(fallback);
+
+ try {
+ firebase.auth().signOut().then(function (unused) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedCallback, "Success: SignOut");
+ }).catch(function (error) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
+ });
+
} catch (error) {
window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
}
@@ -105,6 +158,22 @@ mergeInto(LibraryManager.library, {
window.unityInstance.SendMessage(parsedObjectName, parsedOnUserSignedOut, "User signed out");
}
});
+ },
- }
+ ReloadFirebaseUser: function(objectName, callback, fallback){
+ var parsedObjectName = UTF8ToString(objectName);
+ var parsedCallback = UTF8ToString(callback);
+ var parsedFallback = UTF8ToString(fallback);
+
+ try {
+ firebase.auth().currentUser.reload().then(function (user) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedCallback, JSON.stringify(firebase.auth().currentUser));
+ }).catch(function (error) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
+ });
+
+ } catch (error) {
+ window.unityInstance.SendMessage(parsedObjectName, parsedFallback, JSON.stringify(error, Object.getOwnPropertyNames(error)));
+ }
+ },
});
diff --git a/Assets/FirebaseWebGL/Scripts/FirebaseBridge/FirebaseAuth.cs b/Assets/FirebaseWebGL/Scripts/FirebaseBridge/FirebaseAuth.cs
index f22a1d3..e8b1cc8 100644
--- a/Assets/FirebaseWebGL/Scripts/FirebaseBridge/FirebaseAuth.cs
+++ b/Assets/FirebaseWebGL/Scripts/FirebaseBridge/FirebaseAuth.cs
@@ -56,7 +56,38 @@ public static extern void SignInWithGoogle(string objectName, string callback,
[DllImport("__Internal")]
public static extern void SignInWithFacebook(string objectName, string callback,
string fallback);
-
+
+ ///
+ /// Sends an email verification request
+ ///
+ /// Name of the gameobject to call the callback/fallback of
+ /// Name of the method to call when the operation was successful. Method must have signature: void Method(string output)
+ /// Name of the method to call when the operation was unsuccessful. Method must have signature: void Method(string output). Will return a serialized FirebaseError object
+ [DllImport("__Internal")]
+ public static extern void SendEmailVerification(string objectName, string callback,
+ string fallback);
+
+ ///
+ /// Sends a password reset email
+ ///
+ /// User email
+ /// Name of the gameobject to call the callback/fallback of
+ /// Name of the method to call when the operation was successful. Method must have signature: void Method(string output)
+ /// Name of the method to call when the operation was unsuccessful. Method must have signature: void Method(string output). Will return a serialized FirebaseError object
+ [DllImport("__Internal")]
+ public static extern void SendPasswordResetEmail(string email, string objectName, string callback,
+ string fallback);
+
+ ///
+ /// Signs out the user
+ ///
+ /// Name of the gameobject to call the callback/fallback of
+ /// Name of the method to call when the operation was successful. Method must have signature: void Method(string output)
+ /// Name of the method to call when the operation was unsuccessful. Method must have signature: void Method(string output). Will return a serialized FirebaseError object
+ [DllImport("__Internal")]
+ public static extern void SignOut(string objectName, string callback,
+ string fallback);
+
///
/// Listens for changes of the auth state (sign in/sign out)
///
@@ -66,5 +97,14 @@ public static extern void SignInWithFacebook(string objectName, string callback,
[DllImport("__Internal")]
public static extern void OnAuthStateChanged(string objectName, string onUserSignedIn,
string onUserSignedOut);
+
+ ///
+ /// Reloads the Firebase user
+ ///
+ /// Name of the gameobject to call the onUserSignedIn/onUserSignedOut of
+ /// Name of the method to call when the user signs in. Method must have signature: void Method(string output). Will return a serialized FirebaseUser object
+ /// Name of the method to call when the operation was unsuccessful. Method must have signature: void Method(string output)
+ [DllImport("__Internal")]
+ public static extern void ReloadFirebaseUser(string objectName, string callback, string fallback);
}
}
\ No newline at end of file
diff --git a/Assets/FirebaseWebGL/Scripts/Objects/FirebaseUser.cs b/Assets/FirebaseWebGL/Scripts/Objects/FirebaseUser.cs
index 0b6deea..c82476a 100644
--- a/Assets/FirebaseWebGL/Scripts/Objects/FirebaseUser.cs
+++ b/Assets/FirebaseWebGL/Scripts/Objects/FirebaseUser.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
namespace FirebaseWebGL.Scripts.Objects
{
@@ -7,21 +6,21 @@ namespace FirebaseWebGL.Scripts.Objects
public class FirebaseUser
{
public string displayName;
-
+
public string email;
-
+
public bool isAnonymous;
-
- public bool isEmailVerified;
-
+
+ public bool emailVerified;
+
public FirebaseUserMetadata metadata;
-
+
public string phoneNumber;
-
+
public FirebaseUserProvider[] providerData;
-
+
public string providerId;
-
+
public string uid;
}
}
\ No newline at end of file