mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 03:32:40 +00:00
Merge pull request #2522 from G-Ambatte/fixAccountLoginTime-#2521
[AccountPage] Fix last login time
This commit is contained in:
@@ -340,7 +340,7 @@ app.get('/account', asyncHandler(async (req, res, next)=>{
|
|||||||
if(req.account) {
|
if(req.account) {
|
||||||
if(req.account.googleId) {
|
if(req.account.googleId) {
|
||||||
try {
|
try {
|
||||||
auth = await GoogleActions.authCheck(req.account, res);
|
auth = await GoogleActions.authCheck(req.account, res, false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
auth = undefined;
|
auth = undefined;
|
||||||
console.log('Google auth check failed!');
|
console.log('Google auth check failed!');
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ google.options({ auth: serviceAuth || config.get('google_api_key') });
|
|||||||
|
|
||||||
const GoogleActions = {
|
const GoogleActions = {
|
||||||
|
|
||||||
authCheck : (account, res)=>{
|
authCheck : (account, res, updateTokens=true)=>{
|
||||||
if(!account || !account.googleId){ // If not signed into Google
|
if(!account || !account.googleId){ // If not signed into Google
|
||||||
const err = new Error('Not Signed In');
|
const err = new Error('Not Signed In');
|
||||||
err.status = 401;
|
err.status = 401;
|
||||||
@@ -40,7 +40,7 @@ const GoogleActions = {
|
|||||||
refresh_token : account.googleRefreshToken
|
refresh_token : account.googleRefreshToken
|
||||||
});
|
});
|
||||||
|
|
||||||
oAuth2Client.on('tokens', (tokens)=>{
|
updateTokens && oAuth2Client.on('tokens', (tokens)=>{
|
||||||
if(tokens.refresh_token) {
|
if(tokens.refresh_token) {
|
||||||
account.googleRefreshToken = tokens.refresh_token;
|
account.googleRefreshToken = tokens.refresh_token;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user