auto commit
This commit is contained in:
parent
c3c6cf4c6d
commit
14c6448f1b
@ -1,6 +1,7 @@
|
|||||||
const jwt = require("jsonwebtoken");
|
const jwt = require("jsonwebtoken");
|
||||||
const config = require("../config/config");
|
const config = require("../config/config");
|
||||||
const { User, AuthLog, Company, Branch, Role } = require("../models");
|
const { User, AuthLog, Company, Branch, Role } = require("../models");
|
||||||
|
const logger = require("../config/logger");
|
||||||
|
|
||||||
class AuthService {
|
class AuthService {
|
||||||
async login(username, password, ipAddress, userAgent) {
|
async login(username, password, ipAddress, userAgent) {
|
||||||
@ -37,7 +38,7 @@ class AuthService {
|
|||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Company,
|
model: Company,
|
||||||
attributes: ["id", "name", "businessNumber", "contractEndDate"],
|
attributes: ["id", "name", "businessNumber"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: Branch,
|
model: Branch,
|
||||||
@ -80,16 +81,16 @@ class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async edgeLogin(username, password, businessNumber, ipAddress, userAgent) {
|
async edgeLogin(username, password, businessNumber, ipAddress, userAgent) {
|
||||||
console.log("edge", username, businessNumber);
|
|
||||||
// 1. 먼저 회사 검증
|
// 1. 먼저 회사 검증
|
||||||
const company = await Company.findOne({
|
const company = await Company.findOne({
|
||||||
where: {
|
where: {
|
||||||
businessNumber,
|
businessNumber,
|
||||||
// isActive: true,
|
isActive: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!company) {
|
if (!company) {
|
||||||
|
logger.error(`Company not found: ${businessNumber}`);
|
||||||
throw new Error("Invalid business number or company not found");
|
throw new Error("Invalid business number or company not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +134,8 @@ class AuthService {
|
|||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Company,
|
model: Company,
|
||||||
attributes: ["id", "name", "businessNumber", "contractEndDate"],
|
attributes: ["id", "name", "businessNumber"],
|
||||||
where: { id: company.id, isActive: true }, // 활성화된 회사만
|
where: { isActive: true }, // 활성화된 회사만
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: Branch,
|
model: Branch,
|
||||||
@ -174,7 +175,7 @@ class AuthService {
|
|||||||
const userInfo = {
|
const userInfo = {
|
||||||
...userData,
|
...userData,
|
||||||
permissions,
|
permissions,
|
||||||
// isEdgeLogin: true, // Edge 로그인 여부 표시
|
isEdgeLogin: true, // Edge 로그인 여부 표시
|
||||||
};
|
};
|
||||||
|
|
||||||
const token = this._generateToken(userInfo);
|
const token = this._generateToken(userInfo);
|
||||||
@ -232,9 +233,6 @@ class AuthService {
|
|||||||
id: user.id,
|
id: user.id,
|
||||||
role: user.role,
|
role: user.role,
|
||||||
companyId: user.companyId,
|
companyId: user.companyId,
|
||||||
companyName: user?.Company?.name, // 회사명 추가
|
|
||||||
businessNumber: user?.Company?.businessNumber, // 사업자번호 추가
|
|
||||||
contractEndDate: user?.Company?.contractEndDate, //
|
|
||||||
branchId: user.branchId,
|
branchId: user.branchId,
|
||||||
permissions: user.permissions,
|
permissions: user.permissions,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user