Skip to content

Commit

Permalink
chore: change imports of string operations
Browse files Browse the repository at this point in the history
  • Loading branch information
ourai committed Feb 11, 2025
1 parent 0c7ddb8 commit 18bf909
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
"react-toastify": "^9.1.2",
"react-typed": "^1.2.0",
"recharts": "^2.7.3",
"sass": "^1.64.2",
"sha256": "^0.2.0",
"siwe": "^2.1.4",
"slick-carousel": "^1.8.1",
"striptags": "3.2.0",
"survey-analytics": "^1.9.109",
Expand Down Expand Up @@ -140,6 +138,7 @@
"lint-staged": "15.3.0",
"postcss": "^8.4.18",
"prettier": "^2.5.1",
"sass": "^1.64.2",
"semver": "^7.6.3",
"tailwindcss": "3.4.16"
}
Expand Down
5 changes: 3 additions & 2 deletions src/domain/quiz/views/quiz-question-list/QuizCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/

import clsx from 'clsx';
import { nanoid } from 'nanoid';

import { generateRandomId } from '@/utils';

import RadioIcon from './RadioIcon';

Expand Down Expand Up @@ -72,7 +73,7 @@ export function QuizCore({

return (
<button
key={nanoid()}
key={generateRandomId()}
type="button"
className={clsx('flex items-center gap-x-4 md:block min-h-[48px] py-3 border text-[15px] transition-all rounded mt-6 w-full text-left px-4 border-gray-600 hover:border-gray', {
'!border-gray': checked,
Expand Down
9 changes: 4 additions & 5 deletions src/services/auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@
* limitations under the License.
*/

import sha256 from 'sha256';

import { encryptWithSha256 } from '@/utils/encryption';
import { post } from '@/utils/request';

export async function signin(email, password) {
const res = await post(
'ts/v1/auth/user/email/login/password',
{ email, password: sha256(password) },
{ email, password: encryptWithSha256(password) },
{ isSetJwt: true }
);
return res;
}

export async function reset(key, password) {
const res = await post('ts/v1/auth/user/email/reset/password', { key, password: sha256(password) });
const res = await post('ts/v1/auth/user/email/reset/password', { key, password: encryptWithSha256(password) });
return res;
}

Expand All @@ -53,7 +52,7 @@ export async function bindEmail(email, verification_code) {
export async function registerEmail(email, password, verification_code) {
const res = await post('ts/v1/auth/user/email/register', {
email,
password: sha256(password),
password: encryptWithSha256(password),
verification_code,
});
return res;
Expand Down
17 changes: 17 additions & 0 deletions src/shared/utils/encryption.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright 2024 OpenBuild
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export { default as encryptWithSha256 } from 'sha256';
1 change: 1 addition & 0 deletions src/shared/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ export function HTMLDecode(text) {
}

export { isEmpty, isInteger, isString, isFunction, isPlainObject, get, cloneDeep, merge, capitalize, chunk, range } from 'lodash';
export { nanoid as generateRandomId } from 'nanoid';

0 comments on commit 18bf909

Please sign in to comment.