completed M3 login functionality