force next url register form

stable
Juanfran 2016-05-27 10:15:09 +02:00
parent 389f27880c
commit a09e1a7649
1 changed files with 12 additions and 4 deletions

View File

@ -315,7 +315,7 @@ module.directive("tgLogin", ["$tgAuth", "$tgConfirm", "$tgLocation", "$tgConfig"
## Register Directive ## Register Directive
############################################################################# #############################################################################
RegisterDirective = ($auth, $confirm, $location, $navUrls, $config, $routeParams, $analytics, $translate) -> RegisterDirective = ($auth, $confirm, $location, $navUrls, $config, $routeParams, $analytics, $translate, $window) ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
if not $config.get("publicRegisterEnabled") if not $config.get("publicRegisterEnabled")
$location.path($navUrls.resolve("not-found")) $location.path($navUrls.resolve("not-found"))
@ -324,12 +324,20 @@ RegisterDirective = ($auth, $confirm, $location, $navUrls, $config, $routeParams
$scope.data = {} $scope.data = {}
form = $el.find("form").checksley({onlyOneErrorElement: true}) form = $el.find("form").checksley({onlyOneErrorElement: true})
$scope.nextUrl = $navUrls.resolve("home") console.log $routeParams['forceNext']
if $routeParams['forceNext'] and $routeParams['forceNext'] != $navUrls.resolve("register")
$scope.nextUrl = decodeURIComponent($routeParams['forceNext'])
else
$scope.nextUrl = $navUrls.resolve("home")
onSuccessSubmit = (response) -> onSuccessSubmit = (response) ->
$analytics.trackEvent("auth", "register", "user registration", 1) $analytics.trackEvent("auth", "register", "user registration", 1)
$location.url($scope.nextUrl) if $scope.nextUrl.indexOf('http') == 0
$window.location.href = $scope.nextUrl
else
$location.url($scope.nextUrl)
onErrorSubmit = (response) -> onErrorSubmit = (response) ->
if response.data._error_message if response.data._error_message
@ -357,7 +365,7 @@ RegisterDirective = ($auth, $confirm, $location, $navUrls, $config, $routeParams
return {link:link} return {link:link}
module.directive("tgRegister", ["$tgAuth", "$tgConfirm", "$tgLocation", "$tgNavUrls", "$tgConfig", module.directive("tgRegister", ["$tgAuth", "$tgConfirm", "$tgLocation", "$tgNavUrls", "$tgConfig",
"$routeParams", "$tgAnalytics", "$translate", RegisterDirective]) "$routeParams", "$tgAnalytics", "$translate", "$window", RegisterDirective])
############################################################################# #############################################################################