refactor(core): Extract all Auth-related User columns into a separate entity (#9557)

Co-authored-by: Ricardo Espinoza <ricardo@n8n.io>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-05-31 09:40:19 +02:00
committed by GitHub
parent 08902bf941
commit 5887ed6498
23 changed files with 182 additions and 282 deletions

View File

@@ -742,7 +742,6 @@ export interface CurrentUserResponse extends IUserResponse {
export interface IUser extends IUserResponse {
isDefaultUser: boolean;
isPendingUser: boolean;
hasRecoveryCodesLeft: boolean;
inviteAcceptUrl?: string;
fullName?: string;
createdAt?: string;

View File

@@ -10,7 +10,6 @@ export const createUser = (overrides?: Partial<IUser>): IUser => ({
isDefaultUser: false,
isPending: false,
isPendingUser: false,
hasRecoveryCodesLeft: false,
mfaEnabled: false,
signInType: SignInType.EMAIL,
...overrides,

View File

@@ -28,7 +28,4 @@ export const userFactory = Factory.extend<IUser>({
mfaEnabled() {
return false;
},
hasRecoveryCodesLeft() {
return false;
},
});

View File

@@ -30,7 +30,6 @@ const pinia = createTestingPinia({
lastName: 'Doe',
isDefaultUser: false,
isPendingUser: false,
hasRecoveryCodesLeft: true,
role: ROLE.Owner,
mfaEnabled: false,
},

View File

@@ -148,7 +148,11 @@ export default defineComponent({
this.verifyingMfaToken = true;
this.hasAnyChanges = true;
this.onSubmit({ token: value, recoveryCode: value })
const dataToSubmit = isSubmittingMfaToken
? { token: value, recoveryCode: '' }
: { token: '', recoveryCode: value };
this.onSubmit(dataToSubmit)
.catch(() => {})
.finally(() => (this.verifyingMfaToken = false));
},

View File

@@ -144,7 +144,6 @@ export default defineComponent({
}
await this.settingsStore.getSettings();
this.clearAllStickyNotifications();
this.checkRecoveryCodesLeft();
this.$telemetry.track('User attempted to login', {
result: this.showMfaView ? 'mfa_success' : 'success',
@@ -198,21 +197,6 @@ export default defineComponent({
this.email = form.email;
this.password = form.password;
},
checkRecoveryCodesLeft() {
if (this.usersStore.currentUser) {
const { hasRecoveryCodesLeft, mfaEnabled } = this.usersStore.currentUser;
if (mfaEnabled && !hasRecoveryCodesLeft) {
this.showToast({
title: this.$locale.baseText('settings.mfa.toast.noRecoveryCodeLeft.title'),
message: this.$locale.baseText('settings.mfa.toast.noRecoveryCodeLeft.message'),
type: 'info',
duration: 0,
dangerouslyUseHTMLString: true,
});
}
}
},
},
});
</script>

View File

@@ -24,7 +24,6 @@ const currentUser = {
isDefaultUser: false,
isPendingUser: false,
isPending: false,
hasRecoveryCodesLeft: false,
mfaEnabled: false,
};