使用npm install --save-dev ember-cli-simple-auth
命令为Ember CLI安装了Ember Simple Auth。安装成功了。 ember-cli-simple-auth被添加到node_modules并且一个条目被插入到package.json中。
启动服务器时出现以下错误:
ENOENT, no such file or directory '/Users/xxx/Sites/xxxx-webclient/tmp/tree_merger-tmp_dest_dir-i7zvuTyq.tmp/ember-cli-simple-auth.js'
{
"name": "xxxx-webclient",
"version": "0.0.0",
"private": true,
"directories": {
"doc": "doc",
"test": "test"
},
"scripts": {
"start": "ember server",
"build": "ember build",
"test": "ember test"
},
"repository": "https://github.com/stefanpenner/ember-cli",
"engines": {
"node": ">= 0.10.0"
},
"author": "",
"license": "MIT",
"devDependencies": {
"body-parser": "^1.2.0",
"broccoli-asset-rev": "0.0.17",
"broccoli-ember-hbs-template-compiler": "^1.5.0",
"ember-cli": "0.0.40",
"ember-cli-autoprefixer": "0.0.3",
"ember-cli-ember-data": "0.1.0",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-sass": "^1.0.1",
"ember-cli-simple-auth": "^0.6.4-1",
"express": "^4.1.1",
"glob": "^3.2.9",
"originate": "0.1.5"
}
}
{
"name": "xxx-webclient",
"dependencies": {
"handlebars": "~1.3.0",
"jquery": "^1.11.1",
"qunit": "~1.12.0",
"ember-qunit": "~0.1.8",
"ember": "1.6.1",
"ember-resolver": "~0.1.5",
"loader": "stefanpenner/loader.js#1.0.0",
"ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.2",
"ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2",
"ember-qunit-notifications": "^0.0.3",
"ember-cli-test-loader": "rjackson/ember-cli-test-loader#0.0.2",
"griddler": "~0.0.8",
"parsleyjs": "~2.0.5"
},
"devDependencies": {
"modernizr": "~2.8.3"
}
}
import Ember from 'ember';
import SimpleAuth from 'ember-cli-simple-auth';
import ICAjax from 'ic-ajax';
var XXXAuthorizer = SimpleAuth.Authorizers.Base.extend({
authorize: function(jqXHR, requestOptions) {
//some code
}
});
var XXXAuthenticator = SimpleAuth.Authenticators.Base.extend({
authenticate: function(options) {
// Some Code
},
restore: function(data) {
// some code
}
});
export default {
name: 'authentication',
initialize: function(container, application) {
container.register('authenticator:xxx', XXXAuthenticator);
container.register('authorizer:xxx', XXXAuthorizer);
SimpleAuth.setup(container, application, {
authorizerFactory: 'authorizer:xxx',
routeAfterAuthentication: "dashboard"
});
}
};
感谢您的帮助:)
答案 0 :(得分:0)
simple-auth/authenticators/base
和simple-auth/authorizers/base
import Base from simple-auth/authenticators/base
和
import Base from simple-auth/authorizers/base