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
- Call the
validateUser()
method using an instance ofLMChatClient
. - Pass the
ValidateUserRequest
object containing the user details to validate. - 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.
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
accessToken | String | Access token for the user session | ❌ |
refreshToken | String | Refresh token for the user session | ❌ |
Response
The method returns an LMResponse<ValidateUserResponse>
object.
ValidateUserResponse
This model contains the validation result and additional user details.
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
appAccess | Bool? | Indicates if the user has app access | ✔️ |
community | Community? | Community information of the user | ✔️ |
hasAnswers | Bool? | Indicates if the user has answered prompts | ✔️ |
user | User? | Details of the validated user | ✔️ |