Add expression to read the authenticated user unique identifier (#6192)

* This is useful if you want to interface with a third party or in-house solution to store user data.
This commit is contained in:
Arthur Pacaud (arthuro555)
2024-01-15 14:00:14 +01:00
committed by GitHub
parent d4283c2350
commit 9ed002c879
2 changed files with 18 additions and 1 deletions

View File

@@ -169,6 +169,23 @@ module.exports = {
)
.setFunctionName('gdjs.playerAuthentication.getUsername');
extension
.addStrExpression(
'UserID',
_('User ID'),
_('Get the unique user ID of the authenticated player.'),
'',
'JsPlatform/Extensions/authentication.svg'
)
.getCodeExtraInformation()
.setIncludeFile(
'Extensions/PlayerAuthentication/playerauthenticationcomponents.js'
)
.addIncludeFile(
'Extensions/PlayerAuthentication/playerauthenticationtools.js'
)
.setFunctionName('gdjs.playerAuthentication.getUserId');
extension
.addCondition(
'IsPlayerAuthenticated',

View File

@@ -171,7 +171,7 @@ namespace gdjs {
if (!_checkedLocalStorage) {
readAuthenticatedUserFromLocalStorage();
}
return _userId || null;
return _userId || '';
};
/**