Skip to content
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
1 change: 1 addition & 0 deletions core/i18n/lang/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ErrGroupIsDefault: "Default group, unable to delete"
ErrGroupIsInUse: "The group is in use and cannot be deleted."
ErrLocalDelete: "Cannot delete the local node!"
ErrPortInUsed: "The {{ .name }} port is already in use!"
ErrInternalServerKey: "Internal server error:"

# app
CustomAppStoreFileValid: "Application store package requires .tar.gz format"
Expand Down
1 change: 1 addition & 0 deletions core/i18n/lang/ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ErrGroupIsDefault: "デフォルトグループの削除はできません"
ErrGroupIsInUse: "グループは使用中のため、削除できません。"
ErrLocalDelete: "ローカルノードは削除できません!"
ErrPortInUsed: "{{ .name }} ポートはすでに使用されています!"
ErrInternalServerKey: "サーバー内部エラー:"

# app
CustomAppStoreFileValid: "アプリストアパッケージは .tar.gz 形式である必要があります"
Expand Down
1 change: 1 addition & 0 deletions core/i18n/lang/ko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ErrGroupIsDefault: "기본 그룹은 삭제할 수 없습니다"
ErrGroupIsInUse: "그룹이 사용 중이므로 삭제할 수 없습니다."
ErrLocalDelete: "로컬 노드는 삭제할 수 없습니다!"
ErrPortInUsed: "{{ .name }} 포트가 이미 사용 중입니다!"
ErrInternalServerKey: "서버 내부 오류:"

# app
CustomAppStoreFileValid: "앱 스토어 패키지는 .tar.gz 형식이어야 합니다"
Expand Down
1 change: 1 addition & 0 deletions core/i18n/lang/ms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ErrGroupIsDefault: "Kumpulan lalai tidak boleh dihapuskan"
ErrGroupIsInUse: "Kumpulan sedang digunakan dan tidak boleh dipadam."
ErrLocalDelete: "Nod tempatan tidak boleh dihapuskan!"
ErrPortInUsed: "Port {{ .name }} telah digunakan!"
ErrInternalServerKey: "Ralat dalaman pelayan:"

# app
CustomAppStoreFileValid: "Pakej stor aplikasi perlu dalam format .tar.gz"
Expand Down
1 change: 1 addition & 0 deletions core/i18n/lang/pt-BR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ErrGroupIsDefault: "Grupo padrão não pode ser excluído"
ErrGroupIsInUse: "O grupo está em uso e não pode ser excluído."
ErrLocalDelete: "O nó local não pode ser excluído!"
ErrPortInUsed: "A porta {{ .name }} já está em uso!"
ErrInternalServerKey: "Erro interno do servidor:"

# app
CustomAppStoreFileValid: "O pacote da loja de aplicativos deve estar no formato .tar.gz"
Expand Down
1 change: 1 addition & 0 deletions core/i18n/lang/ru.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ErrGroupIsDefault: "Группу по умолчанию нельзя удали
ErrGroupIsInUse: "Группа используется и не может быть удалена."
ErrLocalDelete: "Локальный узел нельзя удалить!"
ErrPortInUsed: "Порт {{ .name }} уже используется!"
ErrInternalServerKey: "Внутренняя ошибка сервера:"

# app
CustomAppStoreFileValid: "Пакет магазина приложений должен быть в формате .tar.gz"
Expand Down
1 change: 1 addition & 0 deletions core/i18n/lang/zh-Hant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ErrGroupIsDefault: "預設分組無法刪除"
ErrGroupIsInUse: "分組正被使用,無法刪除。"
ErrLocalDelete: "無法刪除本地節點!"
ErrPortInUsed: "{{ .name }} 埠已被佔用!"
ErrInternalServerKey: "服務內部錯誤:"

# app
CustomAppStoreFileValid: "應用商店包需要 .tar.gz 格式"
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/views/login/components/login-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -346,12 +346,14 @@ const login = (formEl: FormInstance | undefined) => {
loginForm.captcha = '';
errCaptcha.value = true;
errAuthInfo.value = false;
loginVerify();
return;
}
if (res.message === 'ErrAuth') {
globalStore.ignoreCaptcha = false;
errCaptcha.value = false;
errAuthInfo.value = true;
loginVerify();
return;
}
MsgError(res.message);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The provided code snippet appears to be part of a function that handles user login logic. Here are some recommendations for checking the code:

  1. Missing Import Statements: Ensure that all necessary imports are included, especially if const { ErrAuth } and MsgError come from other modules.

  2. Function Call: The loginVerify() function is called without arguments inside each conditional block where it is used. Consider whether you need parameters or not.

  3. Variable Names: Variable names like loginForm, errCaptcha, and errAuthInfo should be descriptive but maintain consistency across the application. Avoid abbreviations unless they are widely accepted acronyms.

  4. Return Type: There's no return type specified in this context, which might affect readability. It could be beneficial to use an explicit return type annotation, such as (formEl: FormInstance | undefined) => void.

  5. Global Store Manipulation: Check if accessing or modifying properties of the globalStore is appropriate in this context, especially as ignoreCaptcha can lead to unintended behaviors if not handled carefully.

Here is the revised version with these points considered:

import { globalStore } from './store';

type LoginFormType = {
    captcha: string;
};

const login = (formEl: FormInstance | undefined): boolean => {
    let isLoginSuccessful = false;

    if (formEl !== undefined && !isEmpty(formEl.dataValues)) {
        submitLoginForm((formValue: LoginFormType): Promise<boolean> => {
            return authService.login({ ...formValue });
        })
            .then(response => handleResponse(response))
            .catch(error => handleError(error));
    }

    // Add logic here to determine if login was successful based on response

    return isLoginSuccessful;
}

function isEmpty(obj: any) {
    for (let key of Object.keys(obj)) {
        if (obj.hasOwnProperty(key) && obj[key] !== '') return false;
    }
    return true;
}

async function submitLoginForm(callback: Function): Promise<void> {
    try {
        formEl.setValue('loading', true);
        const promise = callback(formEl.getValue()!);

        if (!promise) throw new Error("No promise returned.");

        await promise;
    } finally {
        formEl.setValue('isLoading', false);
    }
}

function handleResponse(response: any): void {
    switch (response.status) {
        case 'success':
            isLoginSuccessful = true; // Set based on actual success logic
            break;
        case 'error':
            showAlertAndRedirect(response.error || "An error occurred.");
            break;
    }
}

function showAlertAndRedirect(message?: string): void {
    Alert.error(message || "");
    // Redirect after handling error message appropriately
}

This revision includes additional utility functions (isEmpty checks for emptiness), better encapsulating the main functionality into multiple smaller methods, and ensuring proper flow control through asynchronous operations.

Expand Down
Loading