-
Notifications
You must be signed in to change notification settings - Fork 48
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
[2/2] Affiliate program Integration v1 #564
Conversation
The corporate registrations will be manually verified, and activated by podkrepi.bg administrator.
-Added Affiliate model -Removed company field from Person model. That information will now be received from the company relation -Added endpoints to handle adding new affiliates, and updating their status
Would allow us to set default values to fields directly in the dto, which might result in cleaner code.
Affiliate donations will be marked as guaranteed by default
Available only on development/staging enviroment
✅ Tests will run for this PR. Once they succeed it can be merged. |
Removed unnecessary count query. Replaced with the length of the findMany query
Currently the PR says there are 250 files changed, where probably 80% of them were just de-formated -> something that happens when new migrations are generated when running |
Done. Sorry for that. |
Needed in order to show the corporation's name inside the certificate
Needed in order to show the name of the donor on the certificate, if the donation is anonymous
Makes it easier to track whether a corporate profile is enabled or not
Needed for the admin panel
-if metadata is included in the request body -it should not be empty -should contain either name or extraData -extraData should be an object
person: { | ||
firstName: user.given_name, | ||
lastName: user.family_name, |
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.
not a big problem, but still the user names should be already available in the session on the frontend
apps/api/src/auth/auth.service.ts
Outdated
@@ -352,6 +354,12 @@ export class AuthService { | |||
|
|||
async changeEnabledStatus(keycloakId: string, enabled: boolean) { | |||
await this.authenticateAdmin() | |||
// check if user is admin before attempting to activate/deactivate | |||
const userGroups = await this.admin.users.listRoleMappings({ id: keycloakId }) | |||
const isAdmin = userGroups.realmMappings?.some((obj) => obj.name === 'podkrepi-admin') |
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.
who is setting this role? so far we were using the ViewSupporters role for that
@Type(() => TExtraData) | ||
@IsOptional() | ||
//eslint-disable-next-line | ||
extraData: any | ||
extraData: TExtraData | undefined |
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.
might be good to add an example here of the expected structure, because my old mind fails to compile it ;)
…t being sent Apparently the latest changes broke the extraData field. - Removed the unecessary dto extension, as it is enough to validated whether the extraData is Object - Used more specific type of the expected request body of extraData
In keycloak admin access is granted through team-support role - which is compose of view-supporters, view-contact-requests.
7b6ad68
to
8079147
Compare
Closes #512
Motivation and context
Opens donation API for 3rd parties
Testing
Steps to test
1.Creating corporate profile
Endpoint
Body
2.Activate new profile from keycloak
https://localhost:8180
->login
->webapp realm
->Users
->View all users
->Click on profile with [email protected]
->User enabled
->Save
3. Join affiliate program
/login
endpointpending
4. Activating affiliate
Endpoint
Body
af_xxxxx
.5. Creating affiliate donations
Endpoint
Body
6. Cancelling affiliate donation
Endpoint
7. Testing IRIS Response
Endpoint
Body
New endpoints
Affiliate
/affiliate/join
- Endpoint through which corporate user can request to join affiliate program/affiliate/:affiliateId/status-update
- Admin only Endpoint through which affiliate's status can be updated (e.gactive
,rejected
etc.)/affiliate/:affiliateCode/donation
- Endpoint through which active affiliates can make guaranteed donations/affiliate/:affiliateCode/donations/:donationId/cancel
- Endpoint through which active affiliates can cancel guaranteed donation.Bank Transactions
/bank-transaction/iris-transaction-test
- ADMIN/AFFILIATES ONLY DEV ENVIROMENT ONLY Endpoint through which an IRIS response can be simulated