Skip to content
Open
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
14 changes: 8 additions & 6 deletions backend/src/core/modules/auth/service/auth.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AuthRepository } from '../auth.repository';
import { BcryptService } from './bcrypt.service';
import { JwtService } from './jwt.service';
import { UnAuthorizedException, DuplicateException, BadRequestException } from '../../../../packages/httpException';
import { UserActionType } from 'core/common/enum';

class Service {
constructor() {
Expand Down Expand Up @@ -90,16 +91,17 @@ class Service {
fullName: user.full_name,
roleName: user.roles?.name ? user.roles.name.toUpperCase() : null,
avatarUrl: user.avatar_url ?? null,
avatar: user.avatar_url ?? null,
status,
phone: user.phone ?? null,
location: user.location ?? null,
};

if (user.banned_by) {
userData.banned_at = user.updated_at?.toISOString() || null;
userData.bannedAt = user.updated_at?.toISOString() || null;
userData.reason = user.ban_reason ?? null;
userData.status = UserActionType.BANNED;
userData.bannedAt = user.banned_at;
userData.banReason = user.ban_reason;
} else {
userData.status = UserActionType.ACTIVE;
}

const targetUserId = userId ?? user.id;
Expand Down Expand Up @@ -195,7 +197,7 @@ class Service {

return {
data: {
password_reset_token: passwordResetToken,
passwordResetToken: passwordResetToken,
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/core/modules/lawyer/services/lawyer.mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const mapLawyerListItem = user => {
return {
id: user.id,
fullName: user.full_name,
avatar: user.avatar_url,
avatarUrl: user.avatar_url,
careerHistory,
bio,
averageRating: lawyerDetails.rating_avg || 0,
Expand Down
15 changes: 12 additions & 3 deletions backend/src/core/modules/user/services/user.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Service {
return {
id: user.id,
userCode: `USR-${user.id.slice(0, 8).toUpperCase()}`,
avatar: user.avatar_url,
avatarUrl: user.avatar_url,
fullName: user.full_name,
email: user.email,
roleName,
Expand Down Expand Up @@ -109,7 +109,16 @@ class Service {
* Alias for findById (OpenAPI naming)
*/
async getUserById(id) {
return this.findById(id);
const user = await this.findById(id);
if (!user) {
throw new NotFoundException('User not found');
}

return {
data: {
...this.toUserListItem(user),
}
}
}

/**
Expand Down Expand Up @@ -253,7 +262,7 @@ class Service {
data: {
fullName: updatedUser.full_name,
email: updatedUser.email,
avatar: updatedUser.avatar_url,
avatarUrl: updatedUser.avatar_url,
roleName: role.toUpperCase(),
licenseInfo: role === Role.LAWYER.toLowerCase()
? {
Expand Down
Loading