Skip to main content

Validate User

Validates the user session using the provided access and refresh tokens. This method checks if the user has access to the app.

Steps to Validate a User​

  1. Call the validateUser() method using an instance of LMChatClient.
  2. Pass the ValidateUserRequest object containing the user details to validate.
  3. Handle the response using the completion handler to check for success or errors.
let request = ValidateUserRequest.builder()
.accessToken("YOUR_ACCESS_TOKEN")
.refreshToken("YOUR_REFRESH_TOKEN")
.build()

LMChatClient.shared.validateUser(request: request) { response in
switch response {
case .success(let result):
print("User validation successful. App Access: \(result.appAccess == true ? "Granted" : "Denied")")
case .failure(let error):
print("User validation failed: \(error.localizedDescription)")
default:
print("No response received")
}
}

Parameters​

ValidateUserRequest​

The ValidateUserRequest model encapsulates the necessary details to validate a user.

VARIABLETYPEDESCRIPTIONOPTIONAL
accessTokenStringAccess token for the user session❌
refreshTokenStringRefresh token for the user session❌

Response​

The method returns an LMResponse<ValidateUserResponse> object.

ValidateUserResponse​

This model contains the validation result and additional user details.

VARIABLETYPEDESCRIPTIONOPTIONAL
appAccessBool?Indicates if the user has app access✔️
communityCommunity?Community information of the user✔️
hasAnswersBool?Indicates if the user has answered prompts✔️
userUser?Details of the validated user✔️