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.
stable
Andrey Antukh 2014-08-25 18:40:36 +02:00
parent bf15f49d49
commit b94c3a170f
1 changed files with 7 additions and 8 deletions

View File

@ -153,21 +153,16 @@ LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls) -
$scope.data = {} $scope.data = {}
onSuccessSubmit = (response) -> 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") if $routeParams['next'] and $routeParams['next'] != $navUrls.resolve("login")
form.attr("action", $routeParams['next']) nextUrl = $routeParams['next']
else else
form.attr("action", $navUrls.resolve("home")) nextUrl = $navUrls.resolve("home")
form.submit() $location.path(nextUrl)
onErrorSubmit = (response) -> onErrorSubmit = (response) ->
$confirm.notify("light-error", "According to our Oompa Loompas, your username/email $confirm.notify("light-error", "According to our Oompa Loompas, your username/email
or password are incorrect.") #TODO: i18n or password are incorrect.") #TODO: i18n
submit = -> submit = ->
form = $el.find("form").checksley() form = $el.find("form").checksley()
if not form.validate() if not form.validate()
@ -180,6 +175,10 @@ LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls) -
event.preventDefault() event.preventDefault()
submit() submit()
$el.on "submit", "form", (event) ->
event.preventDefault()
submit()
return {link:link} return {link:link}
module.directive("tgLogin", ["$tgAuth", "$tgConfirm", "$location", "$tgConfig", "$routeParams", "$tgNavUrls", module.directive("tgLogin", ["$tgAuth", "$tgConfirm", "$location", "$tgConfig", "$routeParams", "$tgNavUrls",