addon/mixins/osf-agnostic-auth-controller.js - Ember OSF Addon

API Docs for: 0.25.0
Show:

File: addon/mixins/osf-agnostic-auth-controller.js

  1. import Ember from 'ember';
  2. import config from 'ember-get-config';
  3.  
  4. import OsfTokenLoginController from '../mixins/osf-token-login-controller';
  5. import OsfCookieLoginController from '../mixins/osf-cookie-login-controller';
  6.  
  7. /**
  8. * @module ember-osf
  9. * @submodule mixins
  10. */
  11. var AuthMixin;
  12.  
  13. let authType = config.authorizationType;
  14. if (authType === 'token') {
  15. AuthMixin = OsfTokenLoginController;
  16. } else if (authType === 'cookie') {
  17. AuthMixin = OsfCookieLoginController;
  18. } else {
  19. throw new Ember.Error(`Unrecognized authorization type: ${authType}`);
  20. }
  21. /**
  22. * Controller mixin for authentication-agnostic login: defines the application at runtime to use the authentication method
  23. * specified in environment config. Intended to be used in tandem with OsfAuthController mixin.
  24. * Some authentication methods (eg cookies) are not available to third-party applications.
  25. * This has limited use, since most applications will only need to support one method. It may be useful for ember apps
  26. * that run inside the OSF, eg to use the standalone dev server, or to offer support for branded apps
  27. * on third-party domains.
  28. *
  29. * @class OsfAgnosticAuthController
  30. * @extends Ember.Mixin
  31. * @uses ember-osf/OsfCookieLoginController
  32. * @uses ember-osf/OsfTokenLoginController
  33. */
  34. export default AuthMixin;
  35.