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

fix(web): add redirect to page after login #5668

Merged
merged 7 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Scope } from '@nestjs/common';
import { Injectable, Scope, Logger } from '@nestjs/common';
import { MemberRepository } from '@novu/dal';
import { GetFeatureFlag, GetFeatureFlagCommand, createHash } from '@novu/application-generic';
import { FeatureFlagsKeysEnum } from '@novu/shared';
Expand Down Expand Up @@ -37,7 +37,7 @@ export class InviteNudgeWebhook {
});

if (membersCount === 1) {
await axiosInstance.post(
const hubspotAddUserIntoListResponse = await axiosInstance.post(
`https://api.hubapi.com/contacts/v1/lists/${process.env.HUBSPOT_INVITE_NUDGE_EMAIL_USER_LIST_ID}/add`,
{
emails: [command.subscriber.email],
Expand All @@ -48,6 +48,11 @@ export class InviteNudgeWebhook {
},
}
);
if (hubspotAddUserIntoListResponse.data.updated.length !== 1) {
Logger.log(
`Failed to add user ${command.subscriber.email} into list ${process.env.HUBSPOT_INVITE_NUDGE_EMAIL_USER_LIST_ID}`
);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions apps/api/src/app/widgets/widgets.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ export class WidgetsController {
): Promise<LogUsageResponseDto> {
this.analyticsService.track(body.name, subscriberSession._organizationId, {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion : subscriberSession._organizationId should be changed with subscriberSession._userId as per track method params

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

environmentId: subscriberSession._environmentId,
_organization: subscriberSession._organizationId,
...(body.payload || {}),
});

Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/pages/auth/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ type LoginFormProps = {
};

export interface LocationState {
redirectTo: {
pathname: string;
redirectTo?: {
pathname?: string;
};
}

Expand All @@ -38,6 +38,7 @@ export function LoginForm({ email, invitationToken }: LoginFormProps) {
const { isLoading: isLoadingAcceptInvite, acceptInvite } = useAcceptInvite();
const navigate = useNavigate();
const location = useLocation();
const state = location.state as LocationState;
const { isLoading, mutateAsync, isError, error } = useMutation<
{ token: string },
IResponseError,
Expand Down Expand Up @@ -116,7 +117,7 @@ export function LoginForm({ email, invitationToken }: LoginFormProps) {
}
}

navigate(ROUTES.WORKFLOWS);
navigate(state?.redirectTo?.pathname || ROUTES.WORKFLOWS);
} catch (e: any) {
if (e.statusCode !== 400) {
Sentry.captureException(e);
Expand Down
2 changes: 1 addition & 1 deletion libs/shared-web/src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function useAuth() {

useEffect(() => {
if (!getToken() && inPrivateRoute) {
navigate(ROUTES.AUTH_LOGIN);
navigate(ROUTES.AUTH_LOGIN, { state: { redirectTo: location } });
}
}, [navigate, inPrivateRoute]);

Expand Down
Loading