Skip to content

Inserting new record on every login. issue not fixed yet server:oauth mongoose validation when re-login using twitter oauth #1851 #1883

Closed
@waqas19921

Description

@waqas19921

When i added that line

if (authTypes.indexOf(this.provider) !== -1) {
      return respond(true);
    }

in user.model it remove that error

ValidationError: The specified email address is already in use.
   at MongooseError.ValidationError (xxx/node_modules/mongoose/lib/error/validation.js:22:11)
   at model.Document.invalidate (xxx/node_modules/mongoose/lib/document.js:1347:32)
   at xxx/node_modules/mongoose/lib/document.js:1214:17
   at validate (xxx/node_modules/mongoose/lib/schematype.js:693:7)
   at xxx/node_modules/mongoose/lib/schematype.js:721:11
   at user.model.js:122:18
From previous event:
   at model.wrappedPointCut [as save] (xxx/node_modules/mongoose/lib/document.js:1828:14)
   at passport.js:30:16
   at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
   at Strategy._verify (passport.js:12:10)
   at xxx/node_modules/passport-oauth2/lib/strategy.js:193:24
   at xxx/node_modules/passport-github2/lib/strategy.js:121:14
   at passBackControl (xxx/node_modules/oauth/lib/oauth2.js:125:9)
   at IncomingMessage.<anonymous> (xxx/node_modules/oauth/lib/oauth2.js:143:7)
   at emitNone (events.js:85:20)
   at IncomingMessage.emit (events.js:179:7)
   at endReadableNT (_stream_readable.js:913:12)
   at _combinedTickCallback (node.js:377:13)
   at process._tickCallback (node.js:401:11)
validationerror: The specified email address is already in use.   
  at MongooseError.ValidationError (xxx/node_modules/mongoose/lib/error/validation.js:22:11)   
  at model.Document.invalidate (xxx/node_modules/mongoose/lib/document.js:1347:32)   
  at xxx/node_modules/mongoose/lib/document.js:1214:17   
  at validate (xxx/node_modules/mongoose/lib/schematype.js:693:7)   
  at xxx/node_modules/mongoose/lib/schematype.js:721:11   
  at user.model.js:122:18
From previous event:   at model.wrappedPointCut [as save] (xxx/node_modules/mongoose/lib/document.js:1828:14)   
at passport.js:30:16   
at processImmediate [as _immediateCallback] (timers.js:383:17)From previous event:   
at Strategy._verify (passport.js:12:10)   
at xxx/node_modules/passport-oauth2/lib/strategy.js:193:24   
at xxx/node_modules/passport-github2/lib/strategy.js:121:14   
at passBackControl (xxx/node_modules/oauth/lib/oauth2.js:125:9)  
at IncomingMessage.<anonymous> (xxx/node_modules/oauth/lib/oauth2.js:143:7)   
at emitNone (events.js:85:20)   at IncomingMessage.emit (events.js:179:7)   
at endReadableNT (_stream_readable.js:913:12)   
at _combinedTickCallback (node.js:377:13)   
at process._tickCallback (node.js:401:11)

but it stores another record in database so this will populate my db on every twitter login with a new record.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions