I have look for the past few hours trying to find this solution.
My objective: insert logged in account (reactjs front end) into database of saved account token/refresh token(passportjs eveonline)
I have so far gotten passportjs to do the fancy things and store the data in the database. But the only thing is missing, is above. The logged in users session and grab either the username or id of the account.
Reactjs front / nodejs, express, and passportjs-local for my coding.
I'm currently about to pass out cause of my brain wanting to explode from today's coding session. I can provide more details when I wake up.
Edit: Sorry about the delay, here is more details.
Website account is creating the way i want too.
Passport-eveonline is working, BUT it's missing the account details that is currently logged in with ReactJS.
So my task that im trying to do. Is to add the current user logged in (reactjs is keeping them logged in) into the database of where the Eve Characters database gets added into. Would be great to get a guide or possibly assistance in.
I will try my best to give you the answers you guys ask.
This will grab the data from the passport-eveonline.
passport.use(new EveOAuth2Strategy({
clientID: eve_client,
secretKey: eve_secret,
callbackURL: "http://localhost:3001/auth/eveonline/callback",
state: process.env.EVE_STATE,
passReqToCallback: true
},
async function (req, accessToken, refreshToken, profile, cb) {
const character = await Accounts.findOrCreate({ where: { characterID: profile.CharacterID }, defaults: { userID: req.body.id, characterID: profile.CharacterID, characterName: profile.CharacterName, accessToken: accessToken, refreshToken: refreshToken } })
if (character) {
await Accounts.update({ characterID: profile.CharacterID }, { where: { characterID: profile.CharacterID, characterName: profile.CharacterName, accessToken: accessToken, refreshToken: refreshToken } });
return cb(`${profile.CharacterName} has been added/updated. You can close this now \\o/`, null);
}
}
));
Sends the user to the correct URL to select character.
app.get('/auth/eveonline',
passport.authenticate('eveOnline', { scope }));
Callback for when the user selects their eve character.
app.get('/auth/eveonline/callback',
passport.authenticate('eveOnline', {
successRedirect: '/dashboard',
failureRedirect: '/failed',
failWithError: true,
})
);