auto commit
This commit is contained in:
parent
f03a9209ea
commit
c3c6cf4c6d
@ -37,18 +37,15 @@ router.post("/logout", authMiddleware, async (req, res, next) => {
|
|||||||
router.post(
|
router.post(
|
||||||
"/edge-login",
|
"/edge-login",
|
||||||
[
|
[
|
||||||
body("username").notEmpty().withMessage("Username is required"),
|
body("username").notEmpty(),
|
||||||
body("password").notEmpty().withMessage("Password is required"),
|
body("password").notEmpty(),
|
||||||
body("businessNumber")
|
body("businessNumber").notEmpty(),
|
||||||
.notEmpty()
|
|
||||||
.withMessage("Business number is required")
|
|
||||||
.matches(/^[0-9-]{10,20}$/)
|
|
||||||
.withMessage("Invalid business number format"),
|
|
||||||
validate,
|
validate,
|
||||||
],
|
],
|
||||||
async (req, res, next) => {
|
async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const { username, password, businessNumber } = req.body;
|
const { username, password, businessNumber } = req.body;
|
||||||
|
// console.log("edge", username, businessNumber);
|
||||||
const result = await authService.edgeLogin(
|
const result = await authService.edgeLogin(
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
|
@ -37,7 +37,7 @@ class AuthService {
|
|||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Company,
|
model: Company,
|
||||||
attributes: ["id", "name", "businessNumber"],
|
attributes: ["id", "name", "businessNumber", "contractEndDate"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: Branch,
|
model: Branch,
|
||||||
@ -80,11 +80,12 @@ 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,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -132,8 +133,8 @@ class AuthService {
|
|||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: Company,
|
model: Company,
|
||||||
attributes: ["id", "name", "businessNumber"],
|
attributes: ["id", "name", "businessNumber", "contractEndDate"],
|
||||||
where: { isActive: true }, // 활성화된 회사만
|
where: { id: company.id, isActive: true }, // 활성화된 회사만
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: Branch,
|
model: Branch,
|
||||||
@ -173,7 +174,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);
|
||||||
@ -231,6 +232,9 @@ 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,
|
||||||
},
|
},
|
||||||
|
@ -21,7 +21,7 @@ async function createInitialAdmin() {
|
|||||||
if (!adminCompany) {
|
if (!adminCompany) {
|
||||||
adminCompany = await Company.create({
|
adminCompany = await Company.create({
|
||||||
name: "FEMS 관리자",
|
name: "FEMS 관리자",
|
||||||
businessNumber: "000-00-00000",
|
businessNumber: "439-78-02852",
|
||||||
address: "서울시 강남구",
|
address: "서울시 강남구",
|
||||||
tel: "02-0000-0000",
|
tel: "02-0000-0000",
|
||||||
email: "admin@fems.com",
|
email: "admin@fems.com",
|
||||||
|
Loading…
Reference in New Issue
Block a user