Setting up after_login redirects

This commit is contained in:
Will Marshall
2014-05-21 16:39:59 +10:00
parent 0140472fbc
commit 272cb0469f
10 changed files with 42 additions and 14 deletions

View File

@@ -1,8 +1,11 @@
Darkswarm.controller "LoginCtrl", ($scope, $http, $location, AuthenticationService) ->
Darkswarm.controller "LoginCtrl", ($scope, $http, AuthenticationService, Redirections) ->
$scope.path = "/login"
$scope.submit = ->
$http.post("/user/spree_user/sign_in", {spree_user: $scope.spree_user}).success (data)->
location.href = location.origin + location.pathname # Strips out hash fragments
if Redirections.after_login
location.href = location.origin + Redirections.after_login
else
location.href = location.origin + location.pathname # Strips out hash fragments
.error (data) ->
$scope.errors = data.message

View File

@@ -1,4 +1,4 @@
Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location)->
Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redirections)->
new class AuthenticationService
selectedPath: "/login"

View File

@@ -0,0 +1,3 @@
Darkswarm.factory "Redirections", ($location)->
new class Redirections
after_login: $location.search().after_login