userPresent property
bool
userPresent
gets whether a user is authenticated or not, if no user present call any authentication methods first, or if you need to add a new method for your custom provider at strapi, consider adding a extension method on Strapi like
extension MyExtension on Strapi {
Future customAuthentication() async {
final StrapiResponse strapiResponse = await request(
"/auth/my-custom-provider/callback",
method: "GET",
params: {
"customParam1": "value1",
"customParam2": "value2",
},
);
if (strapiResponse.failed) {
//request failed
}
//set the strapiToken making your custom authentication method sucessfull
strapiToken = strapiResponse.body.first["jwt"];
}
}
Implementation
bool get userPresent => strapiToken.isNotEmpty;