mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-19 04:49:15 +00:00
Disable guest checkout for registered users
This commit is contained in:
committed by
Maikel Linke
parent
4551fa60c5
commit
598677be3f
@@ -1,6 +1,13 @@
|
||||
Darkswarm.controller "LoginCtrl", ($scope, $timeout, $location, $http, $window, AuthenticationService, Redirections, Loading) ->
|
||||
$scope.path = "/login"
|
||||
|
||||
$scope.modalMessage = null
|
||||
|
||||
$scope.$watch (->
|
||||
AuthenticationService.modalMessage
|
||||
), (newValue) ->
|
||||
$scope.errors = newValue
|
||||
|
||||
$scope.submit = ->
|
||||
Loading.message = t 'logging_in'
|
||||
$http.post("/user/spree_user/sign_in", {spree_user: $scope.spree_user}).success (data)->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Darkswarm.controller "CheckoutCtrl", ($scope, localStorageService, Checkout, CurrentUser, CurrentHub) ->
|
||||
Darkswarm.controller "CheckoutCtrl", ($scope, localStorageService, Checkout, CurrentUser, CurrentHub, AuthenticationService, SpreeUser, $http) ->
|
||||
$scope.Checkout = Checkout
|
||||
$scope.submitted = false
|
||||
|
||||
@@ -21,7 +21,26 @@ Darkswarm.controller "CheckoutCtrl", ($scope, localStorageService, Checkout, Cur
|
||||
$scope.purchase = (event, form) ->
|
||||
event.preventDefault()
|
||||
$scope.submitted = true
|
||||
|
||||
if CurrentUser.id
|
||||
$scope.validateForm(form)
|
||||
else
|
||||
$scope.confirmGuest(true)
|
||||
|
||||
$scope.validateForm = (form) ->
|
||||
if form.$valid
|
||||
$scope.Checkout.purchase()
|
||||
else
|
||||
$scope.$broadcast 'purchaseFormInvalid', form
|
||||
|
||||
$scope.confirmGuest = ->
|
||||
$http.post("/user/registered_email", {email: $scope.order.email}).success (data)->
|
||||
if data.registered == true
|
||||
$scope.promptLogin()
|
||||
else
|
||||
$scope.validateForm() if $scope.submitted
|
||||
|
||||
$scope.promptLogin = ->
|
||||
SpreeUser.spree_user.email = $scope.order.email
|
||||
AuthenticationService.pushMessage t('devise.failure.already_registered')
|
||||
AuthenticationService.open '/login'
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
Darkswarm.controller "DetailsCtrl", ($scope, $timeout) ->
|
||||
Darkswarm.controller "DetailsCtrl", ($scope, $timeout, $http, CurrentUser, AuthenticationService, SpreeUser) ->
|
||||
angular.extend(this, new FieldsetMixin($scope))
|
||||
$scope.name = "details"
|
||||
$scope.nextPanel = "billing"
|
||||
|
||||
$scope.login_or_next = (event) ->
|
||||
event.preventDefault()
|
||||
unless CurrentUser.id
|
||||
$scope.confirmGuest()
|
||||
|
||||
$scope.next()
|
||||
|
||||
$scope.summary = ->
|
||||
[$scope.fullName(),
|
||||
$scope.order.email,
|
||||
|
||||
@@ -2,6 +2,7 @@ Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redir
|
||||
|
||||
new class AuthenticationService
|
||||
selectedPath: "/login"
|
||||
modalMessage: null
|
||||
|
||||
constructor: ->
|
||||
if $location.path() in ["/login", "/signup", "/forgot"] || location.pathname is '/register/auth'
|
||||
@@ -32,6 +33,8 @@ Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redir
|
||||
'registration_authentication.html'
|
||||
else
|
||||
'authentication.html'
|
||||
pushMessage: (message) ->
|
||||
@modalMessage = String(message)
|
||||
|
||||
select: (path)=>
|
||||
@selectedPath = path
|
||||
|
||||
Reference in New Issue
Block a user