select user_id from activate_user where user_id = :$user_id and activation_hash = :$activation_hash and expires > now() #### INSERT into pending_activations user_id, hash, expiry #### $hash = &generate_hash( $USER, $passwd ); # ... confirm via hash my $ok = $hash eq $USER->{passwd_hash}; # if the hash-compare failed and the user still has a password, use that: if (defined $USER->{passwd}) { ... confirm via passwd }