Login logic on an angularJS application