Set Password Repo
This commit is contained in:
@@ -136,4 +136,51 @@ class AuthRemoteDataProvider {
|
||||
return DC.error(AuthFailure.serverError(e));
|
||||
}
|
||||
}
|
||||
|
||||
Future<DC<AuthFailure, LoginDto>> setPassword({
|
||||
required String registrationToken,
|
||||
required String password,
|
||||
required String confirmPassword,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _apiClient.post(
|
||||
ApiPath.setPassword,
|
||||
data: {
|
||||
'registration_token': registrationToken,
|
||||
'password': password,
|
||||
'confirm_password': confirmPassword,
|
||||
},
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
if ((response.data['errors'] as List).isNotEmpty) {
|
||||
if (response.data['errors'][0]['code'] == "900") {
|
||||
return DC.error(
|
||||
AuthFailure.dynamicErrorMessage(
|
||||
'Invalid Registration, Lakukan kembali dari awal',
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return DC.error(
|
||||
AuthFailure.dynamicErrorMessage(
|
||||
'Terjadi kesalahan coba lagi nanti',
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return DC.error(
|
||||
AuthFailure.dynamicErrorMessage(
|
||||
'Terjadi kesalahan coba lagi nanti',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final dto = LoginDto.fromJson(response.data['data']);
|
||||
return DC.data(dto);
|
||||
} on ApiFailure catch (e, s) {
|
||||
log('setPassword', name: _logName, error: e, stackTrace: s);
|
||||
return DC.error(AuthFailure.serverError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user