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
Changes required for signup flow #62
Conversation
2b3b355
to
4849562
Compare
Current coverage is 86.83% (diff: 92.95%)@@ master #62 diff @@
==========================================
Files 38 38
Lines 506 471 -35
Methods 44 35 -9
Messages 0 0
Branches 52 50 -2
==========================================
- Hits 458 409 -49
- Misses 48 62 +14
Partials 0 0
|
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.
Overall, this has some nice improvements (such as having just one hook for authentication). However, this is a monster PR with lots of design changes we didn't discuss in all detail. Let's talk about it at the office :)
} | ||
}); | ||
}, | ||
local.hooks.hashPassword({ passwordField: 'password' }) |
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.
Please don't use inline hooks of more than 2 lines
class MoodleLoginStrategy extends AbstractLoginStrategy { | ||
constructor(app) { | ||
super(); | ||
this.app = app; | ||
} | ||
|
||
/* | ||
returns a promise with an authenticated client object, or the sign-in error | ||
*/ |
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.
Did this change?
exports.before = { | ||
create: [ | ||
auth.hooks.authenticate(['local', 'jwt']), | ||
(hook) => { |
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.
Same as before
local: new LocalLoginStrategy() | ||
}; | ||
|
||
const docs = { |
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.
Maybe we should include these somewhere in the new file (although feathers-swagger might already provide useful information)
auth.populateUser(), | ||
auth.restrictToAuthenticated()*/ | ||
], | ||
all: [auth.hooks.authenticate('jwt')], |
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.
We should check if authentication should be required for getting information about roles
return hook; | ||
hook.result.displayName = displayName; | ||
hook.result.permissions = permissions; | ||
resolve(hook); |
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'd remove the outer Promise(resolve => ...
and just do .then( _ => Promise.resolve(hook))
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.
Also, see previous
|
||
birthday: {type: Date} | ||
system: {type: Object} // blackbox for frontend stuff like "cookies accepted" |
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 don't get the reason for this, let's talk about it
done(); | ||
}); | ||
}); | ||
}); |
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.
What changed in this file?
}); | ||
}); | ||
|
||
it('should return an error if no password is set', () => { |
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.
What happened to the case that no password is set? Was this test obsolete?
|
||
it('should throw an error if there are two accounts per email, but no systemId is specified', () => { |
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.
What happened to this test case?
Lot of changes here:
Updated all NPM modules (especially
feathers-authentication
with breaking changes)Implemented
displayName
for usersImplemented
system
field for user model to store fronend stuff like "cookies accepted"Refactored
system strategies
from "authentication" to "accounts` (including tests)Removed custom
AuthenticationService
Removed
schoolId
from account modelRemoved
accountIds
from user model (userId is already includes in account model)Notes about refactored authentication:
I refactored it so you can login with an account even if no user is associated. If the account doesn't have a user the user will be redirected to the signup page in frontend to create a user. The userId of the newly created user will be added to the account afterwards and the JWT will be refreshes to include the userId as well.