-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verify email #47
Verify email #47
Conversation
@@ -12,6 +12,7 @@ export interface DBInterface { | |||
findUserByEmail(email: string) : Promise<?UserObjectType>, | |||
findUserByUsername(username: string) : Promise<?UserObjectType>, | |||
findUserById(userId: string) : Promise<?UserObjectType>, | |||
findUserByEmailVerificationToken(token: string) : Promise<?UserObjectType>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the name of the function
packages/server/src/tokens.js
Outdated
@@ -1,5 +1,8 @@ | |||
// @flow | |||
import jwt from 'jsonwebtoken'; | |||
import crypto from 'crypto'; | |||
|
|||
export const generateToken = (length: Int = 43) => crypto.randomBytes(length).toString('hex'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a good place for this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good place. I'd call it generateEmailToken.
message: 'Verify email link expired', | ||
}); | ||
} | ||
const tokenRecord = find(user.services.email.verificationTokens, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TimMikeladze will all dbInterfaces return the user object formatted in the same way ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes they should.
message: 'Verify email link expired', | ||
}); | ||
} | ||
const tokenRecord = find(user.services.email.verificationTokens, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add services to the UserObjectType
message: 'Verify email link expired', | ||
}); | ||
} | ||
const emailRecord = find(user.emails, (e: Object) => e.address === tokenRecord.address); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to make another modification to the UserObjecType and the places it is returned at, since it has a string email
key. Perhaps this could be an explicit call to a this.findEmailByToken
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be the only place we will need this function, I don't think it's necessary to make a special function.
message: 'Verify email link expired', | ||
}); | ||
} | ||
const tokenRecord = find(user.services.email.verificationTokens, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes they should.
packages/server/src/tokens.js
Outdated
@@ -1,5 +1,8 @@ | |||
// @flow | |||
import jwt from 'jsonwebtoken'; | |||
import crypto from 'crypto'; | |||
|
|||
export const generateToken = (length: Int = 43) => crypto.randomBytes(length).toString('hex'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good place. I'd call it generateEmailToken.
Update dependency mongodb to ^3.0.0
Update dependency mongodb to ^3.0.0
No description provided.