fix: error while updating user info

This commit is contained in:
Sergey Yarkov 2022-02-12 22:26:07 +03:00
parent 28fe68aa26
commit 046e3a28f3
3 changed files with 6 additions and 19 deletions

View File

@ -8,11 +8,13 @@
## Added ## Added
- Chat between users. (chat history).
- About description for user and `last_login` column date - About description for user and `last_login` column date
- Updating info api route of authorized user - Updating info api route of authorized user
### Fix ### Fix
- Fixed updating user info
- Cleaning up session store before starting websocket server - Cleaning up session store before starting websocket server
## [1.1.0] - 2022-01-31 ## [1.1.0] - 2022-01-31

View File

@ -314,6 +314,7 @@ export default class MeService {
auth: AuthContract auth: AuthContract
): Promise<IResponse> { ): Promise<IResponse> {
const user = await auth.use(this.authGuard).authenticate(); const user = await auth.use(this.authGuard).authenticate();
const { about, ...newContacts } = data;
if (Object.keys(data).length === 0) { if (Object.keys(data).length === 0) {
return { return {
@ -330,7 +331,7 @@ export default class MeService {
/** /**
* Personal info updating * Personal info updating
*/ */
if (data.about !== undefined) { if (about !== undefined) {
await this.userRepository.updateInfo(user.id, data); await this.userRepository.updateInfo(user.id, data);
} }
@ -338,15 +339,10 @@ export default class MeService {
* Contacts updating * Contacts updating
*/ */
if (data.phone_number !== undefined || data.twitter_id !== undefined || data.telegram_id !== undefined) { if (data.phone_number !== undefined || data.twitter_id !== undefined || data.telegram_id !== undefined) {
const contacts = await this.contactRepository.update(user, { const contacts = await this.contactRepository.update(user, newContacts);
phone_number: data.phone_number,
twitter_id: data.twitter_id,
telegram_id: data.telegram_id,
vk_id: data.vk_id,
});
if (!contacts) { if (!contacts) {
await this.contactRepository.create(user, data); await this.contactRepository.create(user, newContacts);
} }
} }

View File

@ -1,11 +0,0 @@
import Env from '@ioc:Adonis/Core/Env';
import { CloudinaryConfig } from '@ioc:Adonis/Addons/Cloudinary';
const cloudinaryConfig: CloudinaryConfig = {
cloudName: Env.get('CLOUDINARY_CLOUD_NAME'),
apiKey: Env.get('CLOUDINARY_API_KEY'),
apiSecret: Env.get('CLOUDINARY_API_SECRET'),
secure: Env.get('CLOUDINARY_SECURE', true),
};
export default cloudinaryConfig;