pinLogin method
Logs in the user (if successful) using user
& pin
. The session (sessionStatus) is updated accordingly.
Returns the FrappeSessionStatusInfo whether successful or not, wrapped within RequestResponse.
pin
is usually a 4-digit.
Implementation
@override
Future<RequestResponse<FrappeSessionStatusInfo?>> pinLogin(
String user, String pin) async {
await getFrappe().checkAppInstalled(features: ['pinLogin']);
final response = await Request.initiateRequest(
url: config.hostUrl,
method: HttpMethod.POST,
contentType: ContentTypeLiterals.APPLICATION_JSON,
data: <String, dynamic>{
'cmd': 'renovation_core.utils.auth.pin_login',
'user': user,
'pin': pin
});
SessionStatusInfo? sessionStatusInfo;
if (response.isSuccess) {
sessionStatusInfo = FrappeSessionStatusInfo.fromJson(
Request.convertToMap(response.rawResponse!));
sessionStatusInfo.rawSession =
Request.convertToMap(response.rawResponse!);
}
updateSession(
sessionStatus: sessionStatusInfo as FrappeSessionStatusInfo?,
loggedIn: response.isSuccess);
return response.isSuccess
? RequestResponse.success(sessionStatusInfo,
rawResponse: response.rawResponse)
: RequestResponse.fail(handleError('pin_login', response.error));
}