1
に存在するかどうかを確認(https://stormpath.com/blog/build-nodejs-express-stormpath-app)stormpath、発現 - ユーザは、この例での作業経路
Iは経路および任意のユーザの一部がプロファイルアカウント表示するビューを追加しました。正常に動作します
username: jsmith
http://localhost:3000/-jsmith (note the -)
- 。何のユーザーがログインしていない場合であっても
ユーザーが存在しない場合、アプリはちょうどハングし、何も返されません。
/-jsmithxxx
Q:私は、ユーザーが存在するかどうかをテスト、および、 "ユーザーが見つかりません" という表示に戻るにはどうすればよい
?
おかげで、ロブ
app.get('/-:id', function (req, res, next) {
console.log('the response will be sent by the next function ...');
var id = req.params.id;
console.log(id);
next();
},
function (req, res) {
var id = req.params.id;
req.app.get('stormpathApplication').getAccounts({ username: id }, (err, accounts) => {
if (err) throw err;
accounts.each((account, cb) => {
console.log('Found matching account:', account);
cb();
console.log('username:' + account.username)
res.render('user', {
email: account.email,
surname: account.surname,
account:account // this passes object, which can be used in view, no need to define email:account.email in server.js
});
});
});
}
);