Class UserSystem

Inheritance Relationships

Base Type

Class Documentation

class UserSystem : public csp::systems::SystemBase

Public facing system that allows interfacing with Magnopus Connected Services’ user service.

Offers methods for creating accounts, authenticating, and retrieving user profiles.

Public Types

typedef std::function<void(const csp::multiplayer::UserPermissionsParams&)> UserPermissionsChangedCallbackHandler

Public Functions

const LoginState &GetLoginState() const

Get the current login state.

Returns

LoginState : Current login state

void SetNewLoginTokenReceivedCallback(LoginTokenInfoResultCallback Callback)

Sets a callback that will get fired when the login token has changed as a result of logging in with credentials or with a token or after the Connected Spaces Platform internal system has refreshed the session.

In the callback result the token and it’s expiration time will be provided. The expiration time is in OSI format {Year}-{Month}-{Date}T{Hour}:{Min}:{Sec} For C#: register a callback to the OnNewLoginTokenReceived event

Parameters

Callback – LoginTokenInfoResultCallback : callback that gets called as described above

void Login(const csp::common::String &UserName, const csp::common::String &Email, const csp::common::String &Password, const csp::common::Optional<bool> &UserHasVerifiedAge, LoginStateResultCallback Callback)

Log in to Magnopus Connected Services services using a username-password or email-password combination.

Parameters
  • UserNamecsp::common::String

  • Emailcsp::common::String

  • Passwordcsp::common::String

  • UserHasVerifiedAge – csp::common::Optional<bool> : An optional bool to specify whether or not the user has verified that they are over 18

  • Callback – LoginStateResultCallback : callback to call when a response is received

void LoginWithRefreshToken(const csp::common::String &UserId, const csp::common::String &RefreshToken, LoginStateResultCallback Callback)

Resume a previous session for the associated user ID using a refresh token The refresh token can be obtained after registering a callback with SetNewLoginTokenReceivedCallback and logging in regularly.

Parameters
  • UserIdcsp::common::String : User ID for the previous session

  • RefreshTokencsp::common::String : Refresh token to be used for refreshing the authentication token

  • Callback – LoginStateResultCallback : Callback when asynchronous task finishes

void LoginAsGuest(const csp::common::Optional<bool> &UserHasVerifiedAge, LoginStateResultCallback Callback)

Log in to Magnopus Connected Services as a guest.

Parameters
  • UserHasVerifiedAge – csp::common::Optional<bool> : An optional bool to specify whether or not the user has verified that they are over 18

  • Callback – LoginStateResultCallback : callback to call when a response is received

csp::common::Array<EThirdPartyAuthenticationProviders> GetSupportedThirdPartyAuthenticationProviders() const

As a Connected Spaces Platform user the 3rd party authentication flow consists of two steps, first calling GetThirdPartyProviderAuthoriseURL followed by LoginToThirdPartyAuthenticationProvider You can see a Sequence Diagram with all the parties involved including what a Client should be calling and when here https://miro.com/app/board/uXjVPflpu98=/.

API to retrieve the Connected Spaces Platform supported 3rd party authentication providers

Returns

Array of Connected Spaces Platform supported 3rd party authentication providers

void GetThirdPartyProviderAuthoriseURL(EThirdPartyAuthenticationProviders AuthProvider, const csp::common::String &RedirectURL, StringResultCallback Callback)

First step of the 3rd party authentication flow If you call this API but for some reason you’d like to call this again, this is supported, the params you pass second time will replace the ones you’ve passed initially.

Parameters
  • AuthProvider – EThirdPartyAuthenticationProviders : one of the supported Authentication Providers

  • RedirectURLcsp::common::String : the RedirectURL you want to be used for this authentication flow

  • Callback – StringResultCallback : callback that contains the Authorise URL that the Client should be navigating next before moving to the second Connected Spaces Platform Authentication step

void LoginToThirdPartyAuthenticationProvider(const csp::common::String &ThirdPartyToken, const csp::common::String &ThirdPartyStateId, const csp::common::Optional<bool> &UserHasVerifiedAge, LoginStateResultCallback Callback)

Second step of the 3rd party authentication flow Note: The Authentication Provider and the Redirect URL you’ve passed in the first step will be used now.

Parameters
  • ThirdPartyTokencsp::common::String : The authentication token returned by the Provider

  • ThirdPartyStateIdcsp::common::String : The state Id returned by the Provider

  • UserHasVerifiedAge – csp::common::Optional<bool> : An optional bool to specify whether or not the user has verified that they are over 18

  • Callback – LoginStateResultCallback : callback that contains the result of the Magnopus Connected Services Authentication operation

void Logout(NullResultCallback Callback)

Logout from Magnopus Connected Services.

Parameters

Callback – NullResultCallback : callback to call when a response is received

void CreateUser(const csp::common::Optional<csp::common::String> &UserName, const csp::common::Optional<csp::common::String> &DisplayName, const csp::common::String &Email, const csp::common::String &Password, bool ReceiveNewsletter, bool UserHasVerifiedAge, const csp::common::Optional<csp::common::String> &RedirectUrl, const csp::common::Optional<csp::common::String> &InviteToken, ProfileResultCallback Callback)

Creates a new user profile.

Parameters
  • UserName – csp::common::Optional<csp::common::String> : user name associated with the new profile

  • DisplayName – csp::common::Optional<csp::common::String> : user display name associated with the new profile

  • Emailcsp::common::String : email address associated with the new profile

  • Passwordcsp::common::String : password associated with the new profile

  • ReceiveNewsletter – bool : true if the user wants to receive the Magnopus Connected Services newsletter

  • UserHasVerifiedAge – csp::common::Optional<bool> : An optional bool to specify whether or not the user has verified that they are over 18

  • RedirectUrl – csp::common::Optional<csp::common::String> : the URL to redirect the user to after they have registered

  • InviteToken – csp::common::Optional<csp::common::String> : A token provided to the user that can be used to auto-confirm their account

  • Callback – ProfileResultCallback : callback when asynchronous task finishes

void UpgradeGuestAccount(const csp::common::String &UserName, const csp::common::String &DisplayName, const csp::common::String &Email, const csp::common::String &Password, ProfileResultCallback Callback)

Upgrade guest user to full user profile.

Parameters
  • UserNamecsp::common::String : user name associated with the new profile

  • DisplayNamecsp::common::String : user display name associated with the new profile

  • Emailcsp::common::String : email address associated with the new profile

  • Passwordcsp::common::String : password associated with the new profile

  • Callback – ProfileResultCallback : callback when asynchronous task finishes

void ConfirmUserEmail(NullResultCallback Callback)

Send a confirmation email.

Parameters

Callback – NullResultCallback : callback to call when a response is received

void ResetUserPassword(const csp::common::String &Token, const csp::common::String &UserId, const csp::common::String &NewPassword, NullResultCallback Callback)

Reset the users password.

Parameters
  • Tokencsp::common::String : Token received through email by user

  • UserIdcsp::common::String : The id of the user resetting their password

  • NewPasswordcsp::common::String : The new password for the associated account

  • Callback – NullResultCallback : callback to call when a response is received

void UpdateUserDisplayName(const csp::common::String &UserId, const csp::common::String &NewUserDisplayName, NullResultCallback Callback)

Updates the user display name information.

Parameters
  • UserIdcsp::common::String : id of the user that will be updated

  • NewUserDisplayNamecsp::common::String : new display name that will replace the previous value

  • Callback – NullResultCallback : callback when asynchronous task finishes

void DeleteUser(const csp::common::String &UserId, NullResultCallback Callback)

Delete the user.

Note that you need permission to be able to delete the user (You can delete the user you are logged in as).

Parameters
  • UserIdcsp::common::String : id of the user that will be deleted

  • Callback – NullResultCallback : callback when asynchronous task finishes

void ForgotPassword(const csp::common::String &Email, const csp::common::Optional<csp::common::String> &RedirectUrl, const csp::common::Optional<csp::common::String> &EmailLinkUrl, bool UseTokenChangePasswordUrl, NullResultCallback Callback)

Allow a user to reset their password if forgotten by providing an email address.

Parameters
  • Emailcsp::common::String : account to recover password for

  • RedirectUrl – csp::common::Optional<csp::common::String> : the URL to redirect the user to after they have registered

  • EmailLinkUrl – csp::common::Optional<csp::common::String> : the URL inside the reset email sent to the user @Param UseTokenChangePasswordUrl bool : if true the link in the email will direct the user to the Token Change URL

  • Callback – NullResultCallback : callback to call when a response is received

void GetProfileByUserId(const csp::common::String &InUserId, ProfileResultCallback Callback)

Get a user profile by user ID.

Parameters
  • InUserIdcsp::common::String : the ID of the user to get

  • Callback – ProfileResultCallback : callback to call when a response is received

void GetProfilesByUserId(const csp::common::Array<csp::common::String> &InUserIds, BasicProfilesResultCallback Callback)
void GetBasicProfilesByUserId(const csp::common::Array<csp::common::String> &InUserIds, BasicProfilesResultCallback Callback)

Get a list of minimal profiles (avatarId, personalityType, userName, and platform) by user IDs.

Parameters
void Ping(NullResultCallback Callback)

Ping Magnopus Connected Services.

Parameters

Callback – NullResultCallback : callback to call when a response is received

void GetAgoraUserToken(const AgoraUserTokenParams &Params, StringResultCallback Callback)

Retrieve User token from Agora.

Parameters
  • ParamsAgoraUserTokenParams : Params to configure the User token

  • Callback – UserTokenResultCallback : callback to call when a response is received

void ResendVerificationEmail(const csp::common::String &InEmail, const csp::common::Optional<csp::common::String> &InRedirectUrl, NullResultCallback Callback)

Re-send user verification email.

Parameters
  • InEmailcsp::common::String : User’s email address

  • InRedirectUrl – csp::common::Optional<csp::common::String> : URL to redirect user to after they have registered

  • Callback – NullResultCallback : Callback to call when response is received

void GetCustomerPortalUrl(const csp::common::String &UserId, StringResultCallback Callback)

Get the Customer Portal Url for a user from Stripe.

Parameters
  • UserIdcsp::common::String : the id of the user associated with the customer portal

  • Callback – StringResultCallback : callback that contains the customer portal URL of the User

void GetCheckoutSessionUrl(TierNames Tier, StringResultCallback Callback)

Get the checkout session Url for a user from Stripe.

Parameters
  • Tiercsp::systems::TierNames : the tier of the checkout session needed

  • Callback – StringResultCallback : callback that contains the checkout session URL of the tier

void SetUserPermissionsChangedCallback(UserPermissionsChangedCallbackHandler Callback)

Sets a callback for an access control changed event.

Parameters

Callback – UserPermissionsChangedCallbackHandler: Callback to receive data for the user permissions that has been changed.

virtual void RegisterSystemCallback() override

Registers the system to listen for the named event.

virtual void DeregisterSystemCallback() override

Deregisters the system from listening for the named event.

virtual void OnEvent(const std::vector<signalr::value> &EventValues) override

Deserialises the event values of the system.

Parameters

EventValues – std::vector<signalr::value> : event values to deserialise