📌fix: console.log 삭제 ai 테스트
This commit is contained in:
parent
a20b066301
commit
abe86e0adc
@ -6,6 +6,9 @@ import { redirect } from 'next/navigation'
|
|||||||
import { getIronSession } from 'iron-session'
|
import { getIronSession } from 'iron-session'
|
||||||
import { sessionOptions } from './session'
|
import { sessionOptions } from './session'
|
||||||
|
|
||||||
|
import sqlite3 from 'sqlite3'
|
||||||
|
import { open } from 'sqlite'
|
||||||
|
|
||||||
export async function logout() {
|
export async function logout() {
|
||||||
const session = await getSession()
|
const session = await getSession()
|
||||||
session.destroy()
|
session.destroy()
|
||||||
@ -16,9 +19,7 @@ export async function getSession() {
|
|||||||
let session
|
let session
|
||||||
session = await getIronSession(cookies(), sessionOptions)
|
session = await getIronSession(cookies(), sessionOptions)
|
||||||
|
|
||||||
console.log('session:', session)
|
|
||||||
if (!session.isLoggedIn) {
|
if (!session.isLoggedIn) {
|
||||||
// session.isLoggedIn = defaultSession.isLoggedIn
|
|
||||||
session.isLoggedIn = false
|
session.isLoggedIn = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,10 +28,6 @@ export async function getSession() {
|
|||||||
|
|
||||||
export async function checkSession() {
|
export async function checkSession() {
|
||||||
const session = await getSession()
|
const session = await getSession()
|
||||||
|
|
||||||
// if (!session.isLoggedIn) {
|
|
||||||
// redirect('/login')
|
|
||||||
// }
|
|
||||||
return session.isLoggedIn
|
return session.isLoggedIn
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +51,6 @@ export async function setSession(data) {
|
|||||||
session.pwdInitYn = data.pwdInitYn
|
session.pwdInitYn = data.pwdInitYn
|
||||||
session.custCd = data.custCd
|
session.custCd = data.custCd
|
||||||
session.isLoggedIn = true
|
session.isLoggedIn = true
|
||||||
// console.log('session:', session)
|
|
||||||
|
|
||||||
await session.save()
|
await session.save()
|
||||||
}
|
}
|
||||||
@ -64,31 +60,33 @@ export async function login() {
|
|||||||
if (session) {
|
if (session) {
|
||||||
redirect('/')
|
redirect('/')
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// const userId = formData.get('id')
|
|
||||||
// const password = formData.get('password')
|
export const customSetMenuNumber = async ({ objectNo, pid, menuNum, callback = () => {} }) => {
|
||||||
|
let db = null
|
||||||
// console.log('id:', userId)
|
|
||||||
// console.log('password:', password)
|
if (!db) {
|
||||||
|
db = await open({
|
||||||
// // const loginUser = await getUserByIdAndPassword({ userId, password })
|
filename: 'qcast3.global.sqlite',
|
||||||
// const loginUser = {
|
driver: sqlite3.Database,
|
||||||
// id: 1,
|
})
|
||||||
// userId: 'test123',
|
}
|
||||||
// name: 'jinsoo Kim',
|
|
||||||
// email: 'jinsoo.kim@example.com',
|
const chkSql = `SELECT menu_num FROM current_menu WHERE object_no = ? AND pid = ?`
|
||||||
// }
|
const prevMenuNum = await getInstance().get(chkSql, objectNo, pid)
|
||||||
|
|
||||||
// if (!loginUser) {
|
if (prevMenuNum) {
|
||||||
// throw Error('Wrong Credentials!')
|
if (prevMenuNum > menuNum) {
|
||||||
// }
|
callback()
|
||||||
|
} else {
|
||||||
// session.name = loginUser.name
|
const sql = `UPDATE current_menu SET menu_num = ? WHERE object_no = ? AND pid = ?`
|
||||||
// session.userId = loginUser.userId
|
await getInstance().run(sql, menuNum, objectNo, pid)
|
||||||
// session.email = loginUser.email
|
|
||||||
// session.isLoggedIn = true
|
setMenuNumber(menuNum)
|
||||||
// console.log('session:', session)
|
}
|
||||||
|
} else {
|
||||||
// await session.save()
|
const sql = `INSERT INTO current_menu (object_no, pid, menu_num) VALUES (?, ?, ?)`
|
||||||
// redirect('/')
|
await getInstance().run(sql, objectNo, pid, menuNum)
|
||||||
|
setMenuNumber(menuNum)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,16 +72,7 @@ const writeImage = async (fileName, file) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const readImage = async (fileName) => {
|
const readImage = async (fileName) => {
|
||||||
// const file = await fs.readFile(`${FILE_PATH}/${fileName}`)
|
|
||||||
const file = await fs.readFile(`${process.env.NEXT_PUBLIC_HOST_URL}${fileName}`)
|
const file = await fs.readFile(`${process.env.NEXT_PUBLIC_HOST_URL}${fileName}`)
|
||||||
// .then((res) => {
|
|
||||||
// console.log('readImage-then', res)
|
|
||||||
// })
|
|
||||||
// .catch((e) => {
|
|
||||||
// console.log('readImage-catch', e)
|
|
||||||
// })
|
|
||||||
console.log('🚀 ~ readImage ~ file:', file)
|
|
||||||
|
|
||||||
return file
|
return file
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +80,7 @@ const removeImage = async (fileName) => {
|
|||||||
try {
|
try {
|
||||||
await fs.rm(`${FILE_PATH}/${fileName}.png`)
|
await fs.rm(`${FILE_PATH}/${fileName}.png`)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
// Error handling without console.log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user