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

Changes required for signup flow #62

Merged
merged 8 commits into from Jan 18, 2017

Conversation

nicoknoll
Copy link
Contributor

@nicoknoll nicoknoll commented Jan 12, 2017

Lot of changes here:

  • Updated all NPM modules (especially feathers-authentication with breaking changes)

  • Implemented displayName for users

  • Implemented 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 model

  • Removed 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.

@nicoknoll nicoknoll force-pushed the 191-signup-flow-schulen-und-lehrer branch from 2b3b355 to 4849562 Compare January 12, 2017 15:41
@codecov-io
Copy link

codecov-io commented Jan 13, 2017

Current coverage is 86.83% (diff: 92.95%)

Merging #62 into master will decrease coverage by 3.67%

@@             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          

Powered by Codecov. Last update dd80097...c900207

Copy link
Contributor

@MasterCarl MasterCarl left a 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' })
Copy link
Contributor

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
*/
Copy link
Contributor

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) => {
Copy link
Contributor

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 = {
Copy link
Contributor

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')],
Copy link
Contributor

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);
Copy link
Contributor

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))

Copy link
Contributor

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"
Copy link
Contributor

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();
});
});
});
Copy link
Contributor

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', () => {
Copy link
Contributor

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', () => {
Copy link
Contributor

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?

@pinussilvestrus pinussilvestrus merged commit e54ce26 into master Jan 18, 2017
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.

None yet

5 participants