Fixed deadlock on login due to missing lock #670