Skip to content
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

Update last login time in database to fix issue #BB-311 #235

Merged
merged 4 commits into from
Jan 17, 2019

Conversation

akhilesh26
Copy link
Contributor

Problem

The timestamp is same for Joined and Last Active in user's detail.
problem

Solution

The database is updated for last login time.
Update label Last Active to Last login same as MusicBrainz.
solution

Areas of Impact

Client-side: src/client/components/pages/parts/editor-profile.js
Server-side: src/server/routes/auth.js

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 41.399% when pulling c7356c4 on akhilesh26:fix_last_active_issue_BB-311 into 157682e on bookbrainz:master.

@coveralls
Copy link

coveralls commented Jan 17, 2019

Coverage Status

Coverage decreased (-0.05%) to 41.389% when pulling 86f7a0c on akhilesh26:fix_last_active_issue_BB-311 into 157682e on bookbrainz:master.

Copy link
Contributor

@MonkeyDo MonkeyDo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a good fix, it's been bugging me for a while :)

@@ -46,6 +46,13 @@ router.get('/cb', (req, res, next) => {
return next(loginErr);
}

const {Editor} = req.app.locals.orm;
const lastLoginDate = new Date().toISOString();
(() => {
Copy link
Contributor

@MonkeyDo MonkeyDo Jan 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how much I like self-invoking functions. I find they are confusing, especially for a beginner reading the code for the first time.

I would suggest to make the callback passed to .logIn asynchronous, and awaiting the Editor function calls.

In pseudo code, just to make sure I am clear:

return req.logIn(user, async (loginErr) => {
     [...]
     await Editor.where(XYZ).save(XYZ);
     [...]
     return res.redirect(redirectTo);
}

@akhilesh26
Copy link
Contributor Author

Thankyou @MonkeyDo for review,
I have made the required changes. Please review it.
Let me know if any further changes are required.
Thanks.

src/server/routes/auth.js Outdated Show resolved Hide resolved
@MonkeyDo
Copy link
Contributor

Great, thanks @akhilesh26, I'm glad to see this fixed !

@MonkeyDo MonkeyDo merged commit 66e117e into metabrainz:master Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants