amazon-logout.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://aws.amazon.com/apache2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. define([
  16. 'jquery',
  17. 'amazonCore',
  18. 'jquery/ui',
  19. 'mage/cookies'
  20. ], function ($, core) {
  21. 'use strict';
  22. $.widget('amazon.AmazonLogout', {
  23. options: {
  24. onInit: false
  25. },
  26. /**
  27. * Create Amazon Logout Widget
  28. * @private
  29. */
  30. _create: function () {
  31. if (this.options.onInit) {
  32. core.AmazonLogout(); //logout amazon user on init
  33. $.mage.cookies.clear('amazon_Login_accessToken');
  34. }
  35. },
  36. /**
  37. * Logs out a user if called directly
  38. * @private
  39. */
  40. _logoutAmazonUser: function () {
  41. core.AmazonLogout();
  42. $.mage.cookies.clear('amazon_Login_accessToken');
  43. }
  44. });
  45. return $.amazon.AmazonLogout;
  46. });