logOutFromEverywhere function
String
logOutFromEverywhere(
{ - required Entry authDatabase,
- required String username,
- required String password,
})
Implementation
String logOutFromEverywhere({
required Entry authDatabase,
required String username,
required String password,
}){
DbObject? account = _getAccount(
authDatabase: authDatabase,
username: username,
);
if(account == null){
throw "No account found asociated with the username $username.";
}else if(account.view()["username"] == username && account.view()["password"] == password){
//Delete authentication tokens recursively
Map<String,dynamic> accountContent = account.view();
List<dynamic> accessTokens = accountContent["accessTokens"];
for(String token in accessTokens){
try{
_removeAccessToken(
authDatabase: authDatabase,
accessToken: token,
);
}catch(error){
//Prevent error propagation
}
}
}
return "Logged out from all devices successfully.";
}