feat: add some admin translations
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
AdminJS.UserComponents = {}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class QuestionTestId1793536838991 implements MigrationInterface {
|
||||||
|
name = 'QuestionTestId1793536838991'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "question" DROP CONSTRAINT "FK_2c8f911efa2fb5b0fe1abe92020"`);
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."UNQ_TEST_ORDER_IDX"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "question" ALTER COLUMN "testId" SET NOT NULL`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX "UNQ_TEST_ORDER_IDX" ON "question" ("testId", "order") `);
|
||||||
|
await queryRunner.query(`ALTER TABLE "question" ADD CONSTRAINT "FK_2c8f911efa2fb5b0fe1abe92020" FOREIGN KEY ("testId") REFERENCES "test"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "question" DROP CONSTRAINT "FK_2c8f911efa2fb5b0fe1abe92020"`);
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."UNQ_TEST_ORDER_IDX"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "question" ALTER COLUMN "testId" DROP NOT NULL`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX "UNQ_TEST_ORDER_IDX" ON "question" ("order", "testId") `);
|
||||||
|
await queryRunner.query(`ALTER TABLE "question" ADD CONSTRAINT "FK_2c8f911efa2fb5b0fe1abe92020" FOREIGN KEY ("testId") REFERENCES "test"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import { User } from '@/modules/users/entities/user.entity';
|
|||||||
import { RedisService } from '@/common/modules/redis/providers/redis.service';
|
import { RedisService } from '@/common/modules/redis/providers/redis.service';
|
||||||
import { AdminPanelAuthenticator } from './providers/admin-panel-auth.provider';
|
import { AdminPanelAuthenticator } from './providers/admin-panel-auth.provider';
|
||||||
import { AdminPanelSessionStore } from './admin-panel-session.store';
|
import { AdminPanelSessionStore } from './admin-panel-session.store';
|
||||||
|
import fa from './locales/fa';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AdminJS panel bootstrap.
|
* AdminJS panel bootstrap.
|
||||||
@@ -85,9 +86,14 @@ export class AdminPanelSetup {
|
|||||||
|
|
||||||
const adminJs = new AdminJS({
|
const adminJs = new AdminJS({
|
||||||
rootPath: configService.get<string>('admin.rootPath'),
|
rootPath: configService.get<string>('admin.rootPath'),
|
||||||
|
locale: {
|
||||||
|
language: 'fa',
|
||||||
|
translations: fa,
|
||||||
|
},
|
||||||
branding: {
|
branding: {
|
||||||
companyName: 'Heala Admin',
|
companyName: 'پنل ادمین هیلا',
|
||||||
withMadeWithLove: false,
|
withMadeWithLove: false,
|
||||||
|
logo: false,
|
||||||
},
|
},
|
||||||
resources: [
|
resources: [
|
||||||
...autoResources,
|
...autoResources,
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export const MAX_FAILED_ATTEMPTS = 5;
|
||||||
|
export const ATTEMPT_WINDOW_SECONDS = 15 * 60;
|
||||||
|
export const DUMMY_BCRYPT_HASH =
|
||||||
|
'$2b$10$ZFUmcSvMhrye2p.Dt1J7rOcfEdi.NcDLk3Bf55taT3ed57cAcpiNS';
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
const fa = {
|
||||||
|
actions: {
|
||||||
|
new: 'ایجاد',
|
||||||
|
edit: 'ویرایش',
|
||||||
|
show: 'مشاهده',
|
||||||
|
delete: 'حذف',
|
||||||
|
bulkDelete: 'حذف گروهی',
|
||||||
|
list: 'فهرست',
|
||||||
|
search: 'جستجو',
|
||||||
|
filter: 'فیلتر',
|
||||||
|
},
|
||||||
|
|
||||||
|
buttons: {
|
||||||
|
save: 'ذخیره',
|
||||||
|
addNewItem: 'افزودن مورد جدید',
|
||||||
|
filter: 'فیلتر',
|
||||||
|
applyChanges: 'اعمال تغییرات',
|
||||||
|
resetFilter: 'پاک کردن فیلترها',
|
||||||
|
confirmRemovalMany: 'حذف موارد انتخابشده',
|
||||||
|
logout: 'خروج',
|
||||||
|
},
|
||||||
|
|
||||||
|
labels: {
|
||||||
|
navigation: 'منوی اصلی',
|
||||||
|
pages: 'صفحات',
|
||||||
|
selectedRecords: 'موارد انتخابشده',
|
||||||
|
filters: 'فیلترها',
|
||||||
|
dashboard: 'داشبورد',
|
||||||
|
loginWelcome: 'به پنل مدیریت خوش آمدید',
|
||||||
|
},
|
||||||
|
|
||||||
|
messages: {
|
||||||
|
successfullyCreated: 'مورد جدید با موفقیت ایجاد شد.',
|
||||||
|
successfullyUpdated: 'تغییرات با موفقیت ذخیره شد.',
|
||||||
|
successfullyDeleted: 'مورد با موفقیت حذف شد.',
|
||||||
|
successfullyBulkDeleted: 'موارد انتخابشده با موفقیت حذف شدند.',
|
||||||
|
thereWereValidationErrors: 'لطفاً خطاهای فرم را برطرف کنید.',
|
||||||
|
noRecords: 'هیچ موردی یافت نشد.',
|
||||||
|
noRecordsInResource: 'هیچ موردی برای نمایش وجود ندارد.',
|
||||||
|
confirmDelete: 'آیا از حذف این مورد مطمئن هستید؟',
|
||||||
|
loginWelcome: 'برای ورود به پنل مدیریت، اطلاعات خود را وارد کنید.',
|
||||||
|
},
|
||||||
|
|
||||||
|
properties: {},
|
||||||
|
resources: {
|
||||||
|
User: {
|
||||||
|
labels: {
|
||||||
|
User: 'کاربران',
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
id: 'شناسه',
|
||||||
|
firstName: 'نام',
|
||||||
|
lastName: 'نام خانوادگی',
|
||||||
|
phone: 'شماره تلفن',
|
||||||
|
role: 'نقش',
|
||||||
|
createdAt: 'تاریخ ایجاد',
|
||||||
|
updatedAt: 'تاریخ بهروزرسانی',
|
||||||
|
password: 'رمز عبور',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
OTP: {
|
||||||
|
labels: {
|
||||||
|
OTP: 'کدهای تایید',
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
id: 'شناسه',
|
||||||
|
phone: 'شماره تلفن',
|
||||||
|
code: 'کد',
|
||||||
|
expiresAt: 'تاریخ انقضا',
|
||||||
|
used: 'استفاده شده',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Choice: {
|
||||||
|
labels: {
|
||||||
|
Choice: 'گزینه ها',
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
id: 'شناسه',
|
||||||
|
text: 'متن',
|
||||||
|
order: 'ترتیب',
|
||||||
|
score: 'امتیاز',
|
||||||
|
questionId: 'شناسه پرسش',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
QuestionRangeRule: {
|
||||||
|
labels: {
|
||||||
|
QuestionRangeRule: 'قوانین بازهای پرسشها',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
QuestionTransition: {
|
||||||
|
labels: {
|
||||||
|
QuestionTransition: 'مسیر پرسشها',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Question: {
|
||||||
|
labels: {
|
||||||
|
Question: 'پرسشها',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ResultRange: {
|
||||||
|
labels: {
|
||||||
|
ResultRange: 'بازه نتایج آزمایش',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Test: {
|
||||||
|
labels: {
|
||||||
|
Test: 'آزمایش',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
SubmissionAnswer: {
|
||||||
|
labels: {
|
||||||
|
SubmissionAnswer: 'پاسخهای ارسالی',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
SubmissionResult: {
|
||||||
|
labels: {
|
||||||
|
SubmissionResult: 'نتایج آزمایشهای ارسالی',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Submission: {
|
||||||
|
labels: {
|
||||||
|
Submission: 'آزمایشهای ارسالی',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Message: {
|
||||||
|
labels: {
|
||||||
|
Message: 'پیامها',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Conversation: {
|
||||||
|
labels: {
|
||||||
|
Conversation: 'مکالمهها',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {},
|
||||||
|
pages: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default fa;
|
||||||
@@ -4,17 +4,11 @@ import { Role } from '@/common/enums/roles.enum';
|
|||||||
import { UsersService } from '@/modules/users/providers/users.service';
|
import { UsersService } from '@/modules/users/providers/users.service';
|
||||||
import { HashingProvider } from '@/common/modules/hashing/providers/hashing.provider';
|
import { HashingProvider } from '@/common/modules/hashing/providers/hashing.provider';
|
||||||
import { RedisService } from '@/common/modules/redis/providers/redis.service';
|
import { RedisService } from '@/common/modules/redis/providers/redis.service';
|
||||||
|
import {
|
||||||
const MAX_FAILED_ATTEMPTS = 5;
|
ATTEMPT_WINDOW_SECONDS,
|
||||||
const ATTEMPT_WINDOW_SECONDS = 15 * 60;
|
DUMMY_BCRYPT_HASH,
|
||||||
|
MAX_FAILED_ATTEMPTS,
|
||||||
/**
|
} from '../constants';
|
||||||
* Hash of a random throwaway string. Comparing against it when the phone
|
|
||||||
* number is unknown keeps the response time identical to the success path,
|
|
||||||
* so attackers cannot enumerate superuser phone numbers via timing.
|
|
||||||
*/
|
|
||||||
const DUMMY_BCRYPT_HASH =
|
|
||||||
'$2b$10$ZFUmcSvMhrye2p.Dt1J7rOcfEdi.NcDLk3Bf55taT3ed57cAcpiNS';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AdminPanelAuthenticator {
|
export class AdminPanelAuthenticator {
|
||||||
@@ -54,7 +48,8 @@ export class AdminPanelAuthenticator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const user = await this.usersService.findOneByPhone(normalizedPhone);
|
const user = await this.usersService.findOneByPhone(normalizedPhone);
|
||||||
const isSuperuser = !!user && user.role === Role.SUPERUSER;
|
const isSuperuser =
|
||||||
|
!!user && (user.role === Role.SUPERUSER || user.role === Role.ADMIN);
|
||||||
|
|
||||||
const passwordMatches = await this.hashingProvider.compare(
|
const passwordMatches = await this.hashingProvider.compare(
|
||||||
password,
|
password,
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ Content-Type: application/json
|
|||||||
lang: fa
|
lang: fa
|
||||||
|
|
||||||
{
|
{
|
||||||
"phone": "09121212123",
|
"phone": "09333026363"
|
||||||
"password": "Password1@"
|
// "password": "Password1@"
|
||||||
}
|
}
|
||||||
|
|
||||||
{{
|
{{
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ POST {{baseUrl}}/auth/verify-otp
|
|||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"phone": "09121212123",
|
"phone": "09333026363",
|
||||||
"otp": "71288"
|
"otp": "92608"
|
||||||
}
|
}
|
||||||
|
|
||||||
{{
|
{{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
OneToMany,
|
OneToMany,
|
||||||
PrimaryGeneratedColumn,
|
PrimaryGeneratedColumn,
|
||||||
BaseEntity,
|
BaseEntity,
|
||||||
|
JoinColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
import { QuestionType } from '../enums/question-type.enum';
|
import { QuestionType } from '../enums/question-type.enum';
|
||||||
import type { QuestionMetadata } from '../types/question-metadata.type';
|
import type { QuestionMetadata } from '../types/question-metadata.type';
|
||||||
@@ -22,9 +23,17 @@ export class Question extends BaseEntity {
|
|||||||
@PrimaryGeneratedColumn()
|
@PrimaryGeneratedColumn()
|
||||||
id!: number;
|
id!: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
type: 'int',
|
||||||
|
name: 'testId',
|
||||||
|
nullable: false,
|
||||||
|
})
|
||||||
|
testId!: number;
|
||||||
|
|
||||||
@ManyToOne(() => Test, (test) => test.questions, {
|
@ManyToOne(() => Test, (test) => test.questions, {
|
||||||
onDelete: 'CASCADE',
|
onDelete: 'CASCADE',
|
||||||
})
|
})
|
||||||
|
@JoinColumn({ name: 'testId' })
|
||||||
test!: Test;
|
test!: Test;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ Authorization: Bearer {{$global.accessToken}}
|
|||||||
lang: fa
|
lang: fa
|
||||||
|
|
||||||
{
|
{
|
||||||
"firstName": "تست",
|
"firstName": "Radmehr",
|
||||||
"lastName": "تستعلی",
|
"lastName": "Tarnas",
|
||||||
"password": "Password1@",
|
"password": "Password1@",
|
||||||
"confirmPassword": "Password1@"
|
"confirmPassword": "Password1@"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user