device: Do not allow enrolling a finger that is already enrolled

This makes little sense. Users should delete the finger before trying to
enroll the same one again. So throw an error at them from EnrollStart
right away.

Fixes: #95
This commit is contained in:
Benjamin Berg
2020-12-16 15:41:31 +01:00
committed by Marco Trevisan (Treviño)
parent 41086ac4c6
commit bc55deab2a
3 changed files with 19 additions and 0 deletions

View File

@ -1944,6 +1944,8 @@ fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
const char *finger_name)
{
g_autoptr(GError) error = NULL;
g_autoptr(FpPrint) existing_print = NULL;
g_autoptr(SessionData) session = NULL;
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
FpFinger finger = finger_name_to_fp_finger (finger_name);
@ -1962,6 +1964,20 @@ fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
return TRUE;
}
session = session_data_get (priv);
store.print_data_load (priv->dev, finger,
session->username, &existing_print);
if (existing_print)
{
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_FINGER_ALREADY_ENROLLED,
"Finger %d has already been enrolled for user %s", finger, session->username);
g_dbus_method_invocation_return_gerror (invocation,
error);
return TRUE;
}
if (!can_start_action (rdev, &error))
{
g_dbus_method_invocation_return_gerror (invocation, error);