Skip to content

Commit d3339b1

Browse files
committed
feat(Auth): Anonymous login (#126)
* Add anonymous login method * Use new anonymous login method
1 parent 192815a commit d3339b1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Scenes/Login.gd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ func _on_AnonLogin_pressed():
7373
var player_profile_view_constraints = PlayerProfileViewConstraints.new()
7474
combined_info_request_params.ProfileConstraints = player_profile_view_constraints
7575

76+
# If a player has had logged in before, even if anonymous, re-use that login
7677
if PlayFabManager.client_config.login_type == PlayFabClientConfig.LoginType.LOGIN_CUSTOM_ID:
7778
PlayFabManager.client.login_with_custom_id(PlayFabManager.client_config.login_id, false, combined_info_request_params)
7879
else:
79-
PlayFabManager.client.login_with_custom_id(UUID.v4(), true, combined_info_request_params)
80+
PlayFabManager.client.login_anonymous()
8081

8182

8283
func _show_progess():
8384
$ProgressCenter/LoadingIndicator.show()
8485

86+
8587
func _hide_progess():
8688
$ProgressCenter/LoadingIndicator.hide()
8789

addons/godot-playfab/PlayFab.gd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ func login_with_custom_id(custom_id: String, create_user: bool, info_request_par
7373

7474
var result = _post(request_params, "/Client/LoginWithCustomID", Callable(self, "_on_login_with_email"))
7575

76+
# Anonymous login with a GUID as username
77+
func login_anonymous():
78+
var combined_info_request_params = GetPlayerCombinedInfoRequestParams.new()
79+
combined_info_request_params.show_all()
80+
var player_profile_view_constraints = PlayerProfileViewConstraints.new()
81+
combined_info_request_params.ProfileConstraints = player_profile_view_constraints
82+
83+
PlayFabManager.client.login_with_custom_id(UUID.v4(), true, combined_info_request_params)
7684

7785
func _on_register_email_password(result: Dictionary):
7886
var register_result = RegisterPlayFabUserResult.new()

0 commit comments

Comments
 (0)