Ember配置问题

时间:2015-09-08 13:42:00

标签: ember.js ember-data ember-cli ember-simple-auth

我正在尝试为Ember app配置simple-auth-oauth2。正如文档所说http://ember-simple-auth.com/ember-simple-auth-oauth2-api-docs.html

  

Ember Simple Auth OAuth2的配置对象。

     

要更改任何这些值,请在应用程序上设置它们   环境对象:

     

ENV ['simple-auth-oauth2'] = {serverTokenEndpoint:   '/ some / custom / endpoint'}

这是我的配置

//config/environment.js
module.exports = function (environment) {
    var ENV = {
        modulePrefix: 'ember-app',
        environment: environment,
        baseURL: '/',
        API_HOST: '/',
        locationType: 'auto',
        EmberENV: {
            FEATURES: {
                // Here you can enable experimental features on an ember canary build
                // e.g. 'with-controller': true
            }
        },

        APP: {
            // Here you can pass flags/options to your application instance
            // when it is created
        }
    };

    ENV['simple-auth-oauth2'] = {
        serverTokenEndpoint: '/some/custom/endpoint'
    };

    ENV['simple-auth'] = {
        authorizer: 'simple-auth-authorizer:oauth2-bearer'
    };

    return ENV;
};

simple-auth-oauth2继续使用默认值。这不是插件的特别问题,我尝试了另一个扩展('simple-auth-token')并面临完全相同的问题 - 不使用配置。

1 个答案:

答案 0 :(得分:0)

对于https://github.com/simplabs/ember-simple-auth(我有1.1.0版本)

您应该在应用程序中定义您的授权者(如果使用pod结构,它将在application / authorizer.js中(与adapter.js相同的问题):

import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer';
export default OAuth2Bearer.extend();

然后你可以使用:

ENV['ember-simple-auth'] = {
  authorizer: 'simple-auth-authorizer:oauth2-bearer'
};

ENV['simple-auth-oauth2'] = {
  serverTokenEndpoint: <your_backend_endpoint_url>
};

您的配置应该在your_app_name/config/environment.js