docs:api:updateuserpassword
UpdateUserPassword
public static IEnumerator UpdateUserPassword(SupabasePreset supabasePreset,string playerEmail,string currentPassword,string newPassword,System.Action<bool, string> onComplete = null)
Summary:
- Re-authenticates the user and updates their password on Supabase.
- This method first verifies the user's current credentials to obtain a valid access token, then securely updates the password using an authorized request.
- I log the player out whether it was successful or not just incase something failed - cause their password wot update if it fails.
public void UpdatePasswordAndLogOut()
{
string password = LivelyWebGL.Supabase.Auth.SanitizePassword(profilePanel.passwordEditor.currentPassword.text);
string passwordNew = LivelyWebGL.Supabase.Auth.SanitizePassword(profilePanel.passwordEditor.newPassword.text);
string passwordNewAgain = LivelyWebGL.Supabase.Auth.SanitizePassword(profilePanel.passwordEditor.newPasswordAgain.text);
if (password.Length < 8)
{
errorHandler.IssueErrorMessage("Current Password must be more than 7 chars!");
return;
}
else if (passwordNew.Length < 8)
{
errorHandler.IssueErrorMessage("New Password must be more than 7 chars!");
return;
}
else if (!Regex.IsMatch(password, @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_]).+$"))
{
errorHandler.IssueErrorMessage("Password must include at least one uppercase, one lowercase, one number, and one symbol!");
return;
}
else if (string.Compare(passwordNew, passwordNewAgain) == 1)
{
errorHandler.IssueErrorMessage("Passwords do not match");
return;
}
authMain.ShowLoadingScreen();
string email = LivelyWebGL.Supabase.Auth.Session.GetAuthValue("user.email", LivelyWebGL.Supabase.Auth.Session.FlattenedAuthUserdata);
StartCoroutine(LivelyWebGL.Supabase.Auth.Session.UpdateUserPassword(authMain.GetSupabasePreset, email, password, passwordNew, (result, message) =>
{
if (result)
{
authMain.ErrorHandler.IssueErrorMessage("Password updated successfully; Please Log in!");
}
else
{
errorHandler.IssueErrorMessage(message);
}
authMain.HideLoadingScreen();
}));
CancelEdit();
authMain.LogUserOut();
}
docs/api/updateuserpassword.txt · Last modified: by admin
