Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Assets/Talo Game Services/Talo/Runtime/APIs/PlayerAuthAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace TaloGameServices
{
public class PlayerAuthAPI : BaseAPI
{
private SessionManager _sessionManager = new();
private readonly SessionManager _sessionManager = new();

public SessionManager SessionManager => _sessionManager;

Expand Down Expand Up @@ -114,6 +114,19 @@ public async Task ChangeEmail(string currentPassword, string newEmail)
await Call(uri, "POST", content);
}

public async Task ChangeIdentifier(string currentPassword, string newIdentifier)
{
var uri = new Uri($"{baseUrl}/change_identifier");
string content = JsonUtility.ToJson(new PlayerAuthChangeIdentifierRequest {
currentPassword = currentPassword,
newIdentifier = newIdentifier
});
var json = await Call(uri, "POST", content);

var res = JsonUtility.FromJson<PlayerAuthChangeIdentifierResponse>(json);
_sessionManager.HandleIdentifierUpdated(res);
}

public async Task ForgotPassword(string email)
{
var uri = new Uri($"{baseUrl}/forgot_password");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace TaloGameServices
{
[System.Serializable]
public class PlayerAuthChangeIdentifierRequest
{
public string currentPassword;
public string newIdentifier;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace TaloGameServices
{
[System.Serializable]
public class PlayerAuthChangeIdentifierResponse
{
public PlayerAlias alias;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public enum PlayerAuthErrorCode {
NEW_EMAIL_MATCHES_CURRENT_EMAIL,
PASSWORD_RESET_CODE_INVALID,
VERIFICATION_EMAIL_REQUIRED,
INVALID_EMAIL
INVALID_EMAIL,
NEW_IDENTIFIER_MATCHES_CURRENT_IDENTIFIER
}

public class PlayerAuthException : Exception
Expand Down
13 changes: 12 additions & 1 deletion Assets/Talo Game Services/Talo/Runtime/Utils/SessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ public void HandleSessionCreated(PlayerAuthSessionResponse res)
Talo.Socket.SetSocketToken(res.socketToken);
}

private void SetIdentifierPlayerPref()
{
PlayerPrefs.SetString("TaloSessionIdentifier", Talo.CurrentAlias.identifier);
}

private void SaveSession(string sessionToken)
{
PlayerPrefs.SetString("TaloSessionToken", sessionToken);
PlayerPrefs.SetString("TaloSessionIdentifier", Talo.CurrentAlias.identifier);
SetIdentifierPlayerPref();
}

public async Task ClearSession()
Expand All @@ -42,5 +47,11 @@ public bool CheckForSession()
{
return !string.IsNullOrEmpty(GetSessionToken());
}

public void HandleIdentifierUpdated(PlayerAuthChangeIdentifierResponse res)
{
Talo.CurrentAlias = res.alias;
SetIdentifierPlayerPref();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ MonoBehaviour:
m_AtlasBlitShader: {fileID: 9101, guid: 0000000000000000f000000000000000, type: 0}
m_RuntimeShader: {fileID: 9100, guid: 0000000000000000f000000000000000, type: 0}
m_RuntimeWorldShader: {fileID: 9102, guid: 0000000000000000f000000000000000, type: 0}
m_SDFShader: {fileID: 19011, guid: 0000000000000000f000000000000000, type: 0}
m_BitmapShader: {fileID: 9001, guid: 0000000000000000f000000000000000, type: 0}
m_SpriteShader: {fileID: 19012, guid: 0000000000000000f000000000000000, type: 0}
m_ICUDataAsset: {fileID: 0}
forceGammaRendering: 0
textSettings: {fileID: 0}