Skip to content

Instantly share code, notes, and snippets.

@cci-rmirza
Last active October 4, 2022 13:28
Show Gist options
  • Save cci-rmirza/2ea3db2c5982fda0eaf1ceb258dafc10 to your computer and use it in GitHub Desktop.
Save cci-rmirza/2ea3db2c5982fda0eaf1ceb258dafc10 to your computer and use it in GitHub Desktop.
Login and Logout
extension LoginViewController: MembershipShowing {
func login(outletNumber: String, password: String) {
API.authProvider.request(.login(outletNumber: outletNumber, password: password)) { result in
CountlyExceptionHandler.sendLog(result.value, result.error, methodName: AuthService.login(outletNumber: "", password: "").path)
switch result {
case .failure(let error):
// Redacted code because it's unrelated to Countly
case .success(let response):
// Redacted code because it's unrelated to Countly
let deviceIDType = Countly.sharedInstance().deviceIDType()
if deviceIDType == CLYDeviceIDType.custom {
Countly.sharedInstance().setNewDeviceID(outletNumber, onServer: false)
} else {
Countly.sharedInstance().setNewDeviceID(outletNumber, onServer: true)
}
}
}
static func logout() {
API.authProvider.request(AuthService.logout(sessionId: id)) { _ in
// Redacted code because it's unrelated to Countly
Countly.sharedInstance().userLoggedOut()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment