Refactor login form submit handler

Change-Id: Ie610fbbfaaf7683be2985903c57dbdc3b59a6db3