本文整理匯總了TypeScript中@feathersjs/feathers.Application.authenticate方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Application.authenticate方法的具體用法?TypeScript Application.authenticate怎麽用?TypeScript Application.authenticate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@feathersjs/feathers.Application
的用法示例。
在下文中一共展示了Application.authenticate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('authenticate, authentication hook, login event', () => {
const data = {
strategy: 'testing'
};
const promise = new Promise(resolve => {
app.once('login', resolve);
});
app.authenticate(data);
return promise.then(result => {
assert.deepStrictEqual(result, {
accessToken,
data,
user
});
return app.authentication.getAccessToken();
}).then(at => {
assert.strictEqual(at, accessToken, 'Set accessToken in storage');
return Promise.resolve(app.get('storage').getItem('feathers-jwt'));
}).then(at => {
assert.strictEqual(at, accessToken, 'Set accessToken in storage');
return app.service('dummy').find();
}).then(result => {
assert.deepStrictEqual(result.accessToken, accessToken);
assert.deepStrictEqual(result.user, user);
});
});
示例2: it
it('authenticates with local strategy', () => {
return client.authenticate({
strategy: 'local',
email,
password
}).then(result => {
assert.ok(result.accessToken);
assert.strictEqual(result.authentication.strategy, 'local');
assert.strictEqual(result.user.email, email);
});
});