選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

25 行
634 B

  1. const PassportStrategy = require('passport-strategy');
  2. class ServerConnectStrategy extends PassportStrategy {
  3. constructor (options) {
  4. const { provider } = options;
  5. if (!provider) { throw new TypeError('ServerConnectStrategy requires a provider'); }
  6. super();
  7. this.name = 'server-connect';
  8. this._key = provider + 'Id';
  9. }
  10. authenticate (req, options = {}) {
  11. if (req.session && req.session[this._key]) {
  12. const property = req._userProperty || 'user';
  13. req[property] = { id: req.session[this._key] };
  14. }
  15. this.pass();
  16. }
  17. }
  18. module.exports = ServerConnectStrategy;