Resources/contao/models/C4gActivationkeyModel.php
public static function assignUserToKey( $userId, $key )
	{
		$objKey = C4gActivationkeyModel::findBy( 'activationkey', hash('sha256', $key) );
		if (empty( $objKey ) || $objKey->used_by != 0) { return false; }
		$objKey->used_by = $userId;
		$objKey->save();
		return true;
	}
public static function assignUserToKey( $userId, $key )
	{
		$objKey = C4gActivationkeyModel::findBy( 'activationkey', hash('sha256', $key) );
		if (empty( $objKey ) || $objKey->used_by != 0) { return false; }
		$objKey->used_by = $userId;
		$objKey->save();
		return true;
	}
assigns an user to a key, if not already claimed
@param  int $userId
@param  string $key
@return boolean