I have a meteor app and want to migrate non-meteor app. I found account-js is compatible with the meteor account system. When I create new user everything works well but If I want to login with already existed user account-js methods does not work and I get unauth message everytime. How to login with already existed users by using account-js ?
const accountsPassword = new AccountsPassword({
verifyPassword: (plainPassword, storedPassword) => {
const hashedPassword = crypto.Hash('sha256').update(plainPassword).digest('hex')
console.log('*****Verify Password*****')
return bcrypt.compareSync(plainPassword, storedPassword)
}
})
const accountsServer = new AccountsServer(
{
db: accountsMongo
},
{
password: accountsPassword
}
)
const accountsGraphQL = AccountsModule.forRoot({ accountsServer })
const schema = makeExecutableSchema({
typeDefs: mergeTypeDefs([typeDefs, accountsGraphQL.typeDefs]),
resolvers: mergeResolvers([resolvers, accountsGraphQL.resolvers]),
schemaDirectives: {
...accountsGraphQL.schemaDirectives
}
})
const schemaMiddleware = applyMiddleware(schema, permissions)
accounts-js utilizes an entirely different authentication mechanism than Meteor authentication system. accounts-js uses JWT tokens while Meteor uses unique hashes so it's not cross-compatible. I wrote a blog post about it which you can read here