Skip to content

Commit

Permalink
iterate on feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed May 3, 2024
1 parent ab536e4 commit 4341f69
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
57 changes: 57 additions & 0 deletions server/graphql/schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6132,10 +6132,20 @@ type HostApplication {
"""
account: Account!

"""
The host the collective applied to
"""
host: Host!

Check notice on line 6138 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'host' was added to object type 'HostApplication'

Field 'host' was added to object type 'HostApplication'

"""
The date on which the item was created
"""
createdAt: DateTime!

"""
The date on which the item was updated
"""
updatedAt: DateTime!

Check notice on line 6148 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'updatedAt' was added to object type 'HostApplication'

Field 'updatedAt' was added to object type 'HostApplication'
status: HostApplicationStatus
message: String
customData: JSON
Expand Down Expand Up @@ -8393,6 +8403,11 @@ type Collective implements Account & AccountWithHost & AccountWithContributions
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

Check notice on line 8409 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'hostApplication' was added to object type 'Collective'

Field 'hostApplication' was added to object type 'Collective'

"""
How much platform fees are charged for this account
"""
Expand Down Expand Up @@ -8496,6 +8511,11 @@ interface AccountWithHost {
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

Check notice on line 8517 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'hostApplication' was added to interface 'AccountWithHost'

Field 'hostApplication' was added to interface 'AccountWithHost'

"""
Fees percentage that the platform takes for this collective
"""
Expand Down Expand Up @@ -9574,6 +9594,11 @@ type Event implements Account & AccountWithHost & AccountWithContributions & Acc
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

Check notice on line 9600 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'hostApplication' was added to object type 'Event'

Field 'hostApplication' was added to object type 'Event'

"""
How much platform fees are charged for this account
"""
Expand Down Expand Up @@ -15617,6 +15642,11 @@ type Fund implements Account & AccountWithHost & AccountWithContributions {
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

Check notice on line 15648 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'hostApplication' was added to object type 'Fund'

Field 'hostApplication' was added to object type 'Fund'

"""
How much platform fees are charged for this account
"""
Expand Down Expand Up @@ -16465,6 +16495,11 @@ type Project implements Account & AccountWithHost & AccountWithContributions & A
"""
hostFeePercent(paymentMethodService: PaymentMethodService, paymentMethodType: PaymentMethodType): Float

"""
Returns the Fiscal Host application
"""
hostApplication: HostApplication

Check notice on line 16501 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'hostApplication' was added to object type 'Project'

Field 'hostApplication' was added to object type 'Project'

"""
How much platform fees are charged for this account
"""
Expand Down Expand Up @@ -17363,6 +17398,16 @@ type Mutation {
currentPassword: String
): SetPasswordResponse!

"""
Confirm email for Individual. Scope: "account".
"""
confirmEmail(

Check notice on line 17404 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Field 'confirmEmail' was added to object type 'Mutation'

Field 'confirmEmail' was added to object type 'Mutation'
"""
The token to confirm the email.
"""
token: String!
): IndividualConfirmEmailResponse!

"""
Submit a legal document
"""
Expand Down Expand Up @@ -19381,6 +19426,18 @@ type SetPasswordResponse {
token: String
}

type IndividualConfirmEmailResponse {

Check notice on line 19429 in server/graphql/schemaV2.graphql

View workflow job for this annotation

GitHub Actions / GraphQL Inspector - Schema v2

Type 'IndividualConfirmEmailResponse' was added

Type 'IndividualConfirmEmailResponse' was added
"""
The account that was confirmed
"""
individual: Individual!

"""
A new session token to use for the account. Only returned if user is signed in already.
"""
sessionToken: String
}

"""
The `Upload` scalar type represents a file upload.
"""
Expand Down
21 changes: 12 additions & 9 deletions server/graphql/v2/mutation/IndividualMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ const individualMutations = {
type: new GraphQLNonNull(GraphQLIndividual),
description: 'The account that was confirmed',
},
token: {
sessionToken: {
type: GraphQLString,
description: 'A new session token to use for the account. Only returned if not using OAuth.',
description: 'A new session token to use for the account. Only returned if user is signed in already.',
},
},
}),
Expand All @@ -129,25 +129,28 @@ const individualMutations = {
},
},
resolve: async (_, { token: confirmEmailToken }, req) => {
enforceScope(req, 'account');
// Forbid this route for OAuth and Personal Tokens. Remember to check the scope if you want to allow it.
// Also make sure to prevent exchanging OAuth/Personal tokens for session tokens.
if (req.userToken || req.personalToken) {
throw new Unauthorized('OAuth and Personal Tokens are not allowed for this route');
}

const user = await confirmUserEmail(confirmEmailToken);
const individual = await user.getCollective({ loaders: req.loaders });

// The sign-in token
let token;
let sessionToken;

// We don't want OAuth tokens to be exchanged against a session token
if (req.remoteUser && !req.userToken && !req.personalToken) {
// Context: this is token generation when updating password
token = await user.generateSessionToken({
// Re-generate the session token if the user is already signed in
if (req.remoteUser) {
sessionToken = await req.remoteUser.generateSessionToken({
sessionId: req.jwtPayload?.sessionId,
createActivity: false,
updateLastLoginAt: false,
});
}

return { individual, token };
return { individual, sessionToken };
},
},
};
Expand Down

0 comments on commit 4341f69

Please sign in to comment.