Respect next param when toggling between login and register
parent
073bee3185
commit
7d60729c2e
|
@ -203,14 +203,20 @@ module.service("$tgAuth", AuthService)
|
||||||
# Directive that manages the visualization of public register
|
# Directive that manages the visualization of public register
|
||||||
# message/link on login page.
|
# message/link on login page.
|
||||||
|
|
||||||
PublicRegisterMessageDirective = ($config, $navUrls, templates) ->
|
PublicRegisterMessageDirective = ($config, $navUrls, $routeParams, templates) ->
|
||||||
template = templates.get("auth/login-text.html", true)
|
template = templates.get("auth/login-text.html", true)
|
||||||
|
|
||||||
templateFn = ->
|
templateFn = ->
|
||||||
publicRegisterEnabled = $config.get("publicRegisterEnabled")
|
publicRegisterEnabled = $config.get("publicRegisterEnabled")
|
||||||
if not publicRegisterEnabled
|
if not publicRegisterEnabled
|
||||||
return ""
|
return ""
|
||||||
return template({url:$navUrls.resolve("register")})
|
|
||||||
|
url = $navUrls.resolve("register")
|
||||||
|
if $routeParams['next'] and $routeParams['next'] != $navUrls.resolve("login")
|
||||||
|
nextUrl = decodeURIComponent($routeParams['next'])
|
||||||
|
url += "?next=#{nextUrl}"
|
||||||
|
|
||||||
|
return template({url:url})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
restrict: "AE"
|
restrict: "AE"
|
||||||
|
@ -218,22 +224,22 @@ PublicRegisterMessageDirective = ($config, $navUrls, templates) ->
|
||||||
template: templateFn
|
template: templateFn
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgPublicRegisterMessage", ["$tgConfig", "$tgNavUrls", "$tgTemplate",
|
module.directive("tgPublicRegisterMessage", ["$tgConfig", "$tgNavUrls", "$routeParams",
|
||||||
PublicRegisterMessageDirective])
|
"$tgTemplate", PublicRegisterMessageDirective])
|
||||||
|
|
||||||
|
|
||||||
LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls, $events, $translate) ->
|
LoginDirective = ($auth, $confirm, $location, $config, $routeParams, $navUrls, $events, $translate) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
form = new checksley.Form($el.find("form.login-form"))
|
form = new checksley.Form($el.find("form.login-form"))
|
||||||
|
|
||||||
onSuccess = (response) ->
|
if $routeParams['next'] and $routeParams['next'] != $navUrls.resolve("login")
|
||||||
if $routeParams['next'] and $routeParams['next'] != $navUrls.resolve("login")
|
$scope.nextUrl = decodeURIComponent($routeParams['next'])
|
||||||
nextUrl = decodeURIComponent($routeParams['next'])
|
else
|
||||||
else
|
$scope.nextUrl = $navUrls.resolve("home")
|
||||||
nextUrl = $navUrls.resolve("home")
|
|
||||||
|
|
||||||
|
onSuccess = (response) ->
|
||||||
$events.setupConnection()
|
$events.setupConnection()
|
||||||
$location.url(nextUrl)
|
$location.url($scope.nextUrl)
|
||||||
|
|
||||||
onError = (response) ->
|
onError = (response) ->
|
||||||
$confirm.notify("light-error", $translate.instant("LOGIN_FORM.ERROR_AUTH_INCORRECT"))
|
$confirm.notify("light-error", $translate.instant("LOGIN_FORM.ERROR_AUTH_INCORRECT"))
|
||||||
|
@ -271,7 +277,7 @@ module.directive("tgLogin", ["$tgAuth", "$tgConfirm", "$tgLocation", "$tgConfig"
|
||||||
## Register Directive
|
## Register Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
RegisterDirective = ($auth, $confirm, $location, $navUrls, $config, $analytics, $translate) ->
|
RegisterDirective = ($auth, $confirm, $location, $navUrls, $config, $routeParams, $analytics, $translate) ->
|
||||||
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"))
|
||||||
|
@ -280,12 +286,17 @@ RegisterDirective = ($auth, $confirm, $location, $navUrls, $config, $analytics,
|
||||||
$scope.data = {}
|
$scope.data = {}
|
||||||
form = $el.find("form").checksley({onlyOneErrorElement: true})
|
form = $el.find("form").checksley({onlyOneErrorElement: true})
|
||||||
|
|
||||||
|
if $routeParams['next'] and $routeParams['next'] != $navUrls.resolve("login")
|
||||||
|
$scope.nextUrl = decodeURIComponent($routeParams['next'])
|
||||||
|
else
|
||||||
|
$scope.nextUrl = $navUrls.resolve("home")
|
||||||
|
|
||||||
onSuccessSubmit = (response) ->
|
onSuccessSubmit = (response) ->
|
||||||
$analytics.trackEvent("auth", "register", "user registration", 1)
|
$analytics.trackEvent("auth", "register", "user registration", 1)
|
||||||
|
|
||||||
$confirm.notify("success", $translate.instant("LOGIN_FORM.SUCCESS"))
|
$confirm.notify("success", $translate.instant("LOGIN_FORM.SUCCESS"))
|
||||||
|
|
||||||
$location.path($navUrls.resolve("home"))
|
$location.path($scope.nextUrl)
|
||||||
|
|
||||||
onErrorSubmit = (response) ->
|
onErrorSubmit = (response) ->
|
||||||
if response.data._error_message
|
if response.data._error_message
|
||||||
|
@ -313,7 +324,7 @@ RegisterDirective = ($auth, $confirm, $location, $navUrls, $config, $analytics,
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgRegister", ["$tgAuth", "$tgConfirm", "$tgLocation", "$tgNavUrls", "$tgConfig",
|
module.directive("tgRegister", ["$tgAuth", "$tgConfirm", "$tgLocation", "$tgNavUrls", "$tgConfig",
|
||||||
"$tgAnalytics", "$translate", RegisterDirective])
|
"$routeParams", "$tgAnalytics", "$translate", RegisterDirective])
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
p.login-text
|
p.login-text
|
||||||
span(translate="AUTH.NOT_REGISTERED_YET")
|
span(translate="AUTH.NOT_REGISTERED_YET")
|
||||||
|
|
|
|
||||||
a(href!='<%- url %>', tg-nav='register', title='{{"AUTH.REGISTER" | translate}}', translate="AUTH.CREATE_ACCOUNT")
|
a(href!='<%- url %>', title='{{"AUTH.REGISTER" | translate}}', translate="AUTH.CREATE_ACCOUNT")
|
||||||
|
|
|
@ -64,5 +64,6 @@ div.register-form-container(tg-register)
|
||||||
href=""
|
href=""
|
||||||
title="{{'REGISTER_FORM.TITLE_LINK_LOGIN' | translate}}"
|
title="{{'REGISTER_FORM.TITLE_LINK_LOGIN' | translate}}"
|
||||||
tg-nav="login"
|
tg-nav="login"
|
||||||
|
tg-nav-get-params="{\"next\": \"{{nextUrl}}\"}"
|
||||||
translate="REGISTER_FORM.LINK_LOGIN"
|
translate="REGISTER_FORM.LINK_LOGIN"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue