使用 Flask-Stormpath pip。这是设置
app.config['STORMPATH_APPLICATION'] = my_app_name
我在 docs 中没有看到任何 STORMPATH_DIRECTORY 设置|允许开发人员将 applicationA 与多个目录一起使用。
编辑: 对于登录,我提取了 authenticate_password 方法 我可以像兰德尔所说的那样通过特定的导演
authenticate_password(username, password, account_store=self.directory)
对于用户注册,我好像找不到解决办法
这就是我在我的一个应用程序中注册的方式:
authenticate_password(用户名, 密码, account_store=self.directory)
from flask.ext.stormpath import User as StormpathUser
data = {
'email': self._api_user_name_to_email(username),
'password': password,
'given_name': username,
'surname': username,
}
StormpathUser.create(**data)
知道如何在特定目录中明确注册用户吗?
请您参考如下方法:
目前还不支持(首选目录)。在集成中,默认使用您的第一优先级目录来创建新用户等。
如果这对您的用例不起作用,您可以使用 stormpath_manager.application 对象在您想要的任何目录中手动创建用户。
如:
stormpath_manager.application.create_account({...}, account_store=some_other_directory)
