Accounts.registerLoginHandler
メソッドを使用してこれを実現できます。この機能により、開発者はカスタム認証方法を追加できます。詳細については、 https://meteorhacks.com/extending-meteor-accounts.htmlをご覧ください。
を引き続き使用し、 Meteor の accounts-password パッケージ (
Meteor の実装loginWithPassword
を参照) にあるものと同様のものを登録し、Neo4j のデータベース ルックアップに置き換えた呼び出しを使用することをお勧めします。loginHandler
Meteor.users.findOne(selector)
カスタムのログイン方法を使用する場合、コードはhereのコードのようになります (この質問のために変更されています)。このコードは完全ではなく、認証の安全な手段でもないことに注意してください。
// client-side
// This function can be called to log in your users, and will
// trigger the following
Meteor.loginWithNeo4j = function(email, password, callback) {
//create a login request with the email and password passed in
var loginRequest = {email: email, password: password};
//send the login request
Accounts.callLoginMethod({
methodArguments: [loginRequest],
userCallback: callback
});
};
// server-side
Accounts.registerLoginHandler(function(loginRequest) {
// loginRequest is a JS object that will have properties
// "email" and "password as passed in the client code
// -- here you can write code to fetch the user's ID from the database
// take a look at https://github.com/meteor/meteor/blob/devel/packages/accounts-password/password_server.js#L61
// to see how meteor handles password checking
return {
userId: userId
}
});
一般に、アカウント パッケージは MongoDB に多くの依存関係がありますが、認証を機能させるために、パッケージのさまざまなメソッドを組み合わせることができるはずです。