Advisor known as ‘Professor Lockdown’ resigns after breaking rules to meet married lover