Issue666 – User lockout protection

Refering to issue #666. Tests are still missing, but I would like to ask you about a first review before. Don't merge it for now.