Class LoginState

Class Documentation

class LoginState

Data structure representing the user login state, including detection of access token expiry @inv All access to the underlying LoginState data happen under a mutex lock.

Public Functions

LoginState()
~LoginState()
LoginState(const LoginState &OtherState)
LoginState &operator=(const LoginState &OtherState)
std::unique_ptr<LoginStateData> GetSnapshotThreadSafe() const

Get a thread-safe copy of the current login state data.

This is a snapshot of the data at the time of the call, and will not update if the underlying state is mutated.

Returns

A snapshot of the login state data.

void SetLoginStateDataThreadSafe(const csp::common::LoginStateData &NewData)

Set the login state data while guarded by a mutex lock.

This will replace all existing data in the login state with the new data provided.

Parameters

NewData – : The new login state data to set.

bool TrySetLoginRequested()

Attempt to set the login state to LoginRequested if the current state is LoggedOut.

This will prevent multiple concurrent login attempts through use of a mutex guard.

Returns

If the state was successfully changed to LoginRequested.

bool TrySetLogoutRequested()

Attempt to set the login state to LogoutRequested if the current state is LoggedIn.

This will prevent multiple concurrent logout attempts through use of a mutex guard.

Returns

If the state was successfully changed to LogoutRequested.

void ReinitializeResponseLoginState(csp::common::ELoginState LoginState)

Construct a new default login state object after a failed login/logout attempt with the specified ELoginState value.

Parameters

LoginState – : The ELoginState the LoginStateData object should have after reinitialization.

void UpdateAccessTokenExpiry(csp::common::String AccessTokenExpiryLength)

Update the access token expiry time.

Parameters

AccessTokenExpiryLength – : The new access token expiry time length to set.

void UpdateRefreshTokenExpiry(csp::common::String RefreshTokenExpiryLength)

Update the refresh token expiry time.

Parameters

RefreshTokenExpiryLength – : The new refresh token expiry time length to set.

bool RefreshNeeded() const

Check if the access token for the login is expired.

Returns

Is the token expired.

csp::common::String GetUserId() const

Get the user ID of the currently logged-in user.

Returns

The user ID, or an empty string if not logged in.

csp::common::String GetDeviceId() const

Get the device ID of the currently logged-in user.

Returns

The device ID, or an empty string if not logged in.

csp::common::String GetAccessToken() const

Get the access token the currently logged-in user.

Returns

The access token, or an empty string if not logged in.

csp::common::String GetRefreshToken() const

Get the refresh token the currently logged-in user.

Returns

The refresh token, or an empty string if not logged in.

csp::common::ELoginState GetLoginStateValue() const

Get the current login state value.

Returns

The current login state value.

csp::common::List<csp::common::ApplicationSettings> GetDefaultApplicationSettings() const

Get the default tenant-wide application settings returned at login.

Returns

The default application settings.

csp::common::List<csp::common::SettingsCollection> GetDefaultSettings() const

Get the default user settings returned at login.

Returns

The default user settings.