From b94c3a170f549b68c87895d33901b71c94841627 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 25 Aug 2014 18:40:36 +0200 Subject: [PATCH] Remove (awfull) hack and enable submit on press enter key on login. Removed hack does not works. Also, it causes redirects to ugly 405 page of nginx. --- app/coffee/modules/auth.coffee | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/coffee/modules/auth.coffee b/app/coffee/modules/auth.coffee index a105003c..91d2437f 100644 --- a/app/coffee/modules/auth.coffee +++ b/app/coffee/modules/auth.coffee @@ -153,21 +153,16 @@ LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls) - $scope.data = {} onSuccessSubmit = (response) -> - # NOTE: Hack to remember the login form values - form = $el.find("form") - - form.attr("method", "POST") if $routeParams['next'] and $routeParams['next'] != $navUrls.resolve("login") - form.attr("action", $routeParams['next']) + nextUrl = $routeParams['next'] else - form.attr("action", $navUrls.resolve("home")) + nextUrl = $navUrls.resolve("home") - form.submit() + $location.path(nextUrl) onErrorSubmit = (response) -> $confirm.notify("light-error", "According to our Oompa Loompas, your username/email or password are incorrect.") #TODO: i18n - submit = -> form = $el.find("form").checksley() if not form.validate() @@ -180,6 +175,10 @@ LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls) - event.preventDefault() submit() + $el.on "submit", "form", (event) -> + event.preventDefault() + submit() + return {link:link} module.directive("tgLogin", ["$tgAuth", "$tgConfirm", "$location", "$tgConfig", "$routeParams", "$tgNavUrls",