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);

View file

@ -525,6 +525,7 @@
<doc:error name="&ERROR_CLAIM_DEVICE;">if the device was not claimed</doc:error>
<doc:error name="&ERROR_ALREADY_IN_USE;">if the device was already being used</doc:error>
<doc:error name="&ERROR_INVALID_FINGERNAME;">if the finger name passed is invalid</doc:error>
<doc:error name="&FINGER_ALREADY_ENROLLED;">if the finger has been already enrolled by the user</doc:error>
<doc:error name="&ERROR_INTERNAL;">if there was an internal error</doc:error>
</doc:errors>

View file

@ -45,6 +45,8 @@ typedef enum {
FPRINT_ERROR_PERMISSION_DENIED, /*< nick=net.reactivated.Fprint.Error.PermissionDenied >*/
/* No prints are enrolled */
FPRINT_ERROR_NO_ENROLLED_PRINTS, /*< nick=net.reactivated.Fprint.Error.NoEnrolledPrints >*/
/* Prints has already been enrolled */
FPRINT_ERROR_FINGER_ALREADY_ENROLLED, /*< nick=net.reactivated.Fprint.Error.FingerAlreadyEnrolled >*/
/* No actions currently in progress */
FPRINT_ERROR_NO_ACTION_IN_PROGRESS, /*< nick=net.reactivated.Fprint.Error.NoActionInProgress >*/
/* the finger name passed was invalid */