BREAKING - feat(auth): refactor tokens logic & enhance email verification flow (#13487)
- Replaced `getAuthTokensFromLoginToken` with `getAccessTokensFromLoginToken` for clarity. - Introduced `getWorkspaceAgnosticTokenFromEmailVerificationToken`. - Extended mutation inputs to include `locale` and `verifyEmailNextPath`. - Added email verification check and sending to various handlers. - Updated GraphQL types and hooks to reflect these changes. Fix #13412 --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@@ -12,7 +12,10 @@ jest.mock('@/auth/services/AuthService', () => {
|
||||
...initialAuthService,
|
||||
renewToken: jest.fn().mockReturnValue(
|
||||
Promise.resolve({
|
||||
accessToken: { token: 'newAccessToken', expiresAt: '' },
|
||||
accessOrWorkspaceAgnosticToken: {
|
||||
token: 'newAccessToken',
|
||||
expiresAt: '',
|
||||
},
|
||||
refreshToken: { token: 'newRefreshToken', expiresAt: '' },
|
||||
}),
|
||||
),
|
||||
|
||||
@@ -109,8 +109,8 @@ export class ApolloFactory<TCacheShape> implements ApolloManager<TCacheShape> {
|
||||
headers: {
|
||||
...headers,
|
||||
...options.headers,
|
||||
authorization: tokenPair.accessToken.token
|
||||
? `Bearer ${tokenPair.accessToken.token}`
|
||||
authorization: tokenPair.accessOrWorkspaceAgnosticToken.token
|
||||
? `Bearer ${tokenPair.accessOrWorkspaceAgnosticToken.token}`
|
||||
: '',
|
||||
...(this.currentWorkspaceMember?.locale
|
||||
? { 'x-locale': this.currentWorkspaceMember.locale }
|
||||
|
||||
@@ -3,5 +3,8 @@ import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const hasTokenPair = () => {
|
||||
const tokenPair = getTokenPair();
|
||||
return isDefined(tokenPair) && isDefined(tokenPair.accessToken?.token);
|
||||
return (
|
||||
isDefined(tokenPair) &&
|
||||
isDefined(tokenPair.accessOrWorkspaceAgnosticToken?.token)
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user