-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: Create user endpoint, manage team members by email and teamSlugs #2236
Conversation
🤖 Hasura Change Summary compared a subset of table metadata including permissions: Updated Tables (2)
|
0007cf5
to
a07c55c
Compare
const mockGetTeamBySlug = jest.fn().mockResolvedValue(mockTeam); | ||
const mockGetUserByEmail = jest.fn().mockResolvedValue(mockUser); | ||
|
||
jest.mock("@opensystemslab/planx-core", () => { |
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.
At some point soon I'm going to look at how Jest can automock modules - I think this will allow us much easier setup and less repetition.
hasura.planx.uk/metadata/tables.yaml
Outdated
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.
Changes in this file were required as queries were failing which should have been allowed - apologies for the nosie.
return res.status(500).json({ message: "Failed to change role" }); | ||
|
||
res.send({ message: "Successfully changed role" }); | ||
export const changeMemberRole: UpsertMember = async (req, res, next) => { |
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.
These simple methods should show request / response logic handled in the controller, whilst "business logic" is handled in the service.
role, | ||
}: UpsertMember) => { | ||
const $client = getClient(); | ||
const { user, team } = await getUserAndTeam({ userEmail, teamSlug }); |
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.
Doing multiple round trips to the DB to get these details feels pretty awkward. If / when we expose this functionality into the UI it would be worth having userId
and teamId
upfront to make these requests.
Removed vultr server and associated DNS entries |
Moved (briefly!) back to draft - there's a few outstanding docs tidy ups needed I've just noticed on the Pizza sorry! |
Implemented in theopensystemslab/planx-new#2236
- Standardise error handling - Update tests
a07c55c
to
40ed87d
Compare
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.
Used the Swagger docs to test and truly a joy - all worked as expected!
Can very much imagine a near-future workflow where others interact with this too 🎉
new ServerError({ message: "Failed to create user", cause: 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.
would we benefit from a "RemoveUser" here too that, rather than delete the actual record, nullifies the email field to lock them out? Probably not crucial yet, but it feels like the tiny missing piece from an otherwise very useful set of user & team management endpoints ! And it would probably encourage better house-keeping around this.
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.
Good shout - I'll pick this up in a quick follow on PR.
What does this PR do?
platformAdmin
roleDepends on theopensystemslab/planx-core#137