Broker Logout
Overview
When a user logs into any of the brokers via smallcase Gateway for the first time, a user session is created on the smallcase platform (Eg: in the case of zerodha, it is smallcase.zerodha.com).
From next time onwards when the user interacts with the smallcase gateway SDK, the SDK will check for an active session on the smallcase platform before asking the user to log in. And if the session exists, login journey is skipped.
This definitely improves the user experience for the repeating users.
However, this might not work for users who want to switch to another account for the same broker. Say, a user has two Zerodha account, AB1234, and YZ5678. If they logged in with their first account, there will be an active session on Zerodha's smallcase platform. But next time when they try to transact, they would not have option to login with second account, since session with first account exists.
To tackle this experience, we have a logout mechanism using which "connected" users can be logged out from smallcase platform. This is as simple as invoking a method.
smallcase Gateway SDK must be initialised with connected user auth token.
Technical details
Javascript SDK
Method: brokerLogout
Example:
// initiate gateway
const scGateway = new scDK({
gateway: <gateway_name>,
smallcaseAuthToken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzbWFsbGNhc2VBdXRoSWQiOiI2MDdlNmQ1MjJlZmU1MzQ3OTZlMzFkMzYiLCJleHAiOjE2MzE3MDA2NTAsImlhdCI6MTYzMTYxNDI1MH0.kWT3LM1MSQJKe-SqNi4dfWsF13jlKWWasKpGZJkhtko',
config: {
amo: true
}
})
// logout from smallcase platform
scGateway.brokerLogout();
Android SDK
Method: logoutUser
Parameters:
-
activity
: (required): Current activity reference -
logoutListener
: (required) : triggered once the logout is complete with success/
failed with error.
Example:
SmallcaseGatewaySdk.logoutUser(activity!!, object : SmallcaseLogoutListener {
override fun onLogoutSuccessfull() {
//perform actions on successful logout
}
override fun onLogoutFailed(errorCode: Int, error: String) {
//perform actions on logout failed
}
})
iOS SDK
Method: logoutUser
Parameters:
-
presentingController
(required): Current view controller reference -
Completion
(required): Optional Result type with success(bool) and error.
Triggered after logout is completed.
Example:
SCGateway.shared.logoutUser(presentingController: self) { result in
switch result {
case .success(let response):
//perform actions on successful logout
case .failure(let error):
//perform actions on logout failed
}
}