Q.CAST 자동로그인 추가 및 비밀번호 변경 팝업 수정
This commit is contained in:
parent
e7d988bba6
commit
ee34bd549c
@ -16,8 +16,7 @@ import Cookies from 'js-cookie'
|
|||||||
import { useSearchParams } from 'next/navigation'
|
import { useSearchParams } from 'next/navigation'
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login() {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
// 자동 로그인
|
||||||
// 자동 로그인 작업진행중
|
|
||||||
const initParams = useSearchParams()
|
const initParams = useSearchParams()
|
||||||
const autoLoginParam = initParams.get('autoLoginParam1')
|
const autoLoginParam = initParams.get('autoLoginParam1')
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -26,45 +25,27 @@ export default function Login() {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
const autoLoginProcess = async (autoLoginParam) => {
|
const autoLoginProcess = async (autoLoginParam) => {
|
||||||
setSession({
|
await promisePost({ url: '/api/login/v1.0/user/login/autoLoginDecryptData', data: { loginId: autoLoginParam } })
|
||||||
userId: autoLoginParam,
|
.then((res) => {
|
||||||
saleStoreId: null,
|
if (res) {
|
||||||
name: null,
|
if (res.data) {
|
||||||
mail: null,
|
post({ url: '/api/login/v1.0/user', data: { loginId: res.data } }).then((response) => {
|
||||||
tel: null,
|
if (response) {
|
||||||
storeId: 'TEMP02',
|
const result = { ...response, storeLvl: response.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' }
|
||||||
userNm: 'ㅇㅇ6610',
|
setSession(result)
|
||||||
userNmKana: '신규사용자 16610',
|
setSessionState(result)
|
||||||
category: '인상6610',
|
router.push('/')
|
||||||
telNo: '336610',
|
} else {
|
||||||
fax: null,
|
router.push('/login')
|
||||||
email: 't10t@naver.com',
|
}
|
||||||
pwdInitYn: 'Y',
|
})
|
||||||
storeLvl: '2',
|
}
|
||||||
groupId: '70000',
|
}
|
||||||
})
|
})
|
||||||
|
.catch((error) => {
|
||||||
setSessionState({
|
router.push('/login')
|
||||||
userId: autoLoginParam,
|
})
|
||||||
saleStoreId: null,
|
|
||||||
name: null,
|
|
||||||
mail: null,
|
|
||||||
tel: null,
|
|
||||||
storeId: 'TEMP02',
|
|
||||||
userNm: 'ㅇㅇ6610',
|
|
||||||
userNmKana: '신규사용자 16610',
|
|
||||||
category: '인상6610',
|
|
||||||
telNo: '336610',
|
|
||||||
fax: null,
|
|
||||||
email: 't10t@naver.com',
|
|
||||||
pwdInitYn: 'Y',
|
|
||||||
storeLvl: '2',
|
|
||||||
groupId: '70000',
|
|
||||||
})
|
|
||||||
|
|
||||||
router.push('/')
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
const [userId, setUserId] = useState('')
|
const [userId, setUserId] = useState('')
|
||||||
const [checkId, setCheckId] = useState('')
|
const [checkId, setCheckId] = useState('')
|
||||||
@ -86,12 +67,14 @@ export default function Login() {
|
|||||||
|
|
||||||
const [passwordReset, setPasswordReset] = useState(1)
|
const [passwordReset, setPasswordReset] = useState(1)
|
||||||
|
|
||||||
const { promisePost, promisePatch } = useAxios(globalLocaleState)
|
const { promisePost, promisePatch, post } = useAxios(globalLocaleState)
|
||||||
|
|
||||||
// login process
|
// login process
|
||||||
const loginProcess = async (e) => {
|
const loginProcess = async (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
const formData = new FormData(e.target)
|
const formData = new FormData(e.target)
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
// 임시 로그인 처리
|
// 임시 로그인 처리
|
||||||
setSession({
|
setSession({
|
||||||
userId: 'NEW016610',
|
userId: 'NEW016610',
|
||||||
@ -110,7 +93,6 @@ export default function Login() {
|
|||||||
storeLvl: '1',
|
storeLvl: '1',
|
||||||
groupId: '60000',
|
groupId: '60000',
|
||||||
})
|
})
|
||||||
|
|
||||||
setSessionState({
|
setSessionState({
|
||||||
userId: 'NEW016610',
|
userId: 'NEW016610',
|
||||||
saleStoreId: null,
|
saleStoreId: null,
|
||||||
@ -128,16 +110,14 @@ export default function Login() {
|
|||||||
storeLvl: '1',
|
storeLvl: '1',
|
||||||
groupId: '60000',
|
groupId: '60000',
|
||||||
})
|
})
|
||||||
|
|
||||||
// ID SAVE 체크되어 있는 경우, 쿠키 저장
|
|
||||||
if (chkLoginId) {
|
if (chkLoginId) {
|
||||||
Cookies.set('chkLoginId', formData.get('id'), { expires: 7 })
|
Cookies.set('chkLoginId', formData.get('id'), { expires: 7 })
|
||||||
} else {
|
} else {
|
||||||
Cookies.remove('chkLoginId')
|
Cookies.remove('chkLoginId')
|
||||||
}
|
}
|
||||||
|
|
||||||
router.push('/')
|
router.push('/')
|
||||||
// 임시 로그인 처리 끝
|
// 임시 로그인 처리 끝
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// 로그인 처리 시작 - ** 상단 임시 로그인 추후 삭제 필요 **
|
// 로그인 처리 시작 - ** 상단 임시 로그인 추후 삭제 필요 **
|
||||||
// const param = {
|
// const param = {
|
||||||
@ -173,7 +153,6 @@ export default function Login() {
|
|||||||
loginId: checkId,
|
loginId: checkId,
|
||||||
email: checkEmail,
|
email: checkEmail,
|
||||||
}
|
}
|
||||||
|
|
||||||
await promisePatch({
|
await promisePatch({
|
||||||
url: '/api/login/v1.0/user/init-password',
|
url: '/api/login/v1.0/user/init-password',
|
||||||
data: param,
|
data: param,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export default function UserInfoModal({ userId, userInfoModal, setUserInfoModal
|
|||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
|
|
||||||
// api 조회 관련
|
// api 조회 관련
|
||||||
const { get, promisePatch } = useAxios()
|
const { get, promisePatch, promisePost } = useAxios()
|
||||||
const [info, setInfo] = useState({
|
const [info, setInfo] = useState({
|
||||||
userId: '',
|
userId: '',
|
||||||
name: '',
|
name: '',
|
||||||
@ -25,6 +25,7 @@ export default function UserInfoModal({ userId, userInfoModal, setUserInfoModal
|
|||||||
const [showPwd, setShowPwd] = useState(false)
|
const [showPwd, setShowPwd] = useState(false)
|
||||||
const [chkChgPwd, setChkChgPwd] = useState(false)
|
const [chkChgPwd, setChkChgPwd] = useState(false)
|
||||||
const [chgPwd, setChgPwd] = useState('')
|
const [chgPwd, setChgPwd] = useState('')
|
||||||
|
const pwdInput = useRef()
|
||||||
const chgPwdInput = useRef()
|
const chgPwdInput = useRef()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -54,7 +55,7 @@ export default function UserInfoModal({ userId, userInfoModal, setUserInfoModal
|
|||||||
const handleChangePassword = async () => {
|
const handleChangePassword = async () => {
|
||||||
if (chgPwd === '') {
|
if (chgPwd === '') {
|
||||||
chgPwdInput.current.focus()
|
chgPwdInput.current.focus()
|
||||||
return alert(getMessage('myinfo.message.validation.password1'))
|
return alert(getMessage('myinfo.message.validation.password4'))
|
||||||
}
|
}
|
||||||
if (password === chgPwd) {
|
if (password === chgPwd) {
|
||||||
chgPwdInput.current.focus()
|
chgPwdInput.current.focus()
|
||||||
@ -73,6 +74,8 @@ export default function UserInfoModal({ userId, userInfoModal, setUserInfoModal
|
|||||||
if (res.data.result.resultCode === 'S') {
|
if (res.data.result.resultCode === 'S') {
|
||||||
alert(getMessage('myinfo.message.save'))
|
alert(getMessage('myinfo.message.save'))
|
||||||
setChkChgPwd(false)
|
setChkChgPwd(false)
|
||||||
|
setPassword(chgPwd)
|
||||||
|
setChgPwd('')
|
||||||
} else {
|
} else {
|
||||||
alert(res.data.result.resultMsg)
|
alert(res.data.result.resultMsg)
|
||||||
}
|
}
|
||||||
@ -83,6 +86,40 @@ export default function UserInfoModal({ userId, userInfoModal, setUserInfoModal
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 비밀번호 변경 버튼 클릭 시,
|
||||||
|
const checkPasswordProcess = async (e) => {
|
||||||
|
if (password === '') {
|
||||||
|
pwdInput.current.focus()
|
||||||
|
return alert(getMessage('myinfo.message.validation.password1'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const param = {
|
||||||
|
loginId: userId,
|
||||||
|
pwd: password,
|
||||||
|
}
|
||||||
|
await promisePost({ url: '/api/login/v1.0/login', data: param })
|
||||||
|
.then((res) => {
|
||||||
|
if (res) {
|
||||||
|
if (res.data.result.resultCode === 'S') {
|
||||||
|
setChkChgPwd(true)
|
||||||
|
setTimeout(() => {
|
||||||
|
chgPwdInput.current.focus()
|
||||||
|
}, 10)
|
||||||
|
} else {
|
||||||
|
alert(getMessage('myinfo.message.password.error'))
|
||||||
|
setChkChgPwd(false)
|
||||||
|
setChgPwd('')
|
||||||
|
setTimeout(() => {
|
||||||
|
pwdInput.current.focus()
|
||||||
|
}, 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
alert(error.response.data.message)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="modal-popup">
|
<div className="modal-popup">
|
||||||
@ -141,6 +178,7 @@ export default function UserInfoModal({ userId, userInfoModal, setUserInfoModal
|
|||||||
<input
|
<input
|
||||||
type={`${showPwd ? 'text' : 'password'}`}
|
type={`${showPwd ? 'text' : 'password'}`}
|
||||||
value={password}
|
value={password}
|
||||||
|
ref={pwdInput}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setPassword(e.target.value)
|
setPassword(e.target.value)
|
||||||
}}
|
}}
|
||||||
@ -151,11 +189,8 @@ export default function UserInfoModal({ userId, userInfoModal, setUserInfoModal
|
|||||||
<button
|
<button
|
||||||
className="btn-origin grey mr5"
|
className="btn-origin grey mr5"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={(e) => {
|
||||||
setChkChgPwd(true)
|
checkPasswordProcess(e)
|
||||||
setTimeout(() => {
|
|
||||||
chgPwdInput.current.focus()
|
|
||||||
}, 10)
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{getMessage('myinfo.btn.chg.password')}
|
{getMessage('myinfo.btn.chg.password')}
|
||||||
|
|||||||
@ -376,7 +376,9 @@
|
|||||||
"myinfo.message.validation.password1": "パスワードを入力してください。",
|
"myinfo.message.validation.password1": "パスワードを入力してください。",
|
||||||
"myinfo.message.validation.password2": "既存のパスワードと同じです。",
|
"myinfo.message.validation.password2": "既存のパスワードと同じです。",
|
||||||
"myinfo.message.validation.password3": "半角文字10文字以内で入力してください。",
|
"myinfo.message.validation.password3": "半角文字10文字以内で入力してください。",
|
||||||
|
"myinfo.message.validation.password4": "変更パスワードを入力してください。",
|
||||||
"myinfo.message.save": "パスワードが変更されました。",
|
"myinfo.message.save": "パスワードが変更されました。",
|
||||||
|
"myinfo.message.password.error": "パスワードが間違っています。",
|
||||||
"login": "ログイン",
|
"login": "ログイン",
|
||||||
"login.id.save": "ID保存",
|
"login.id.save": "ID保存",
|
||||||
"login.id.placeholder": "IDを入力してください。",
|
"login.id.placeholder": "IDを入力してください。",
|
||||||
|
|||||||
@ -381,7 +381,9 @@
|
|||||||
"myinfo.message.validation.password1": "비밀번호를 입력하세요.",
|
"myinfo.message.validation.password1": "비밀번호를 입력하세요.",
|
||||||
"myinfo.message.validation.password2": "기존 비밀번호와 동일합니다.",
|
"myinfo.message.validation.password2": "기존 비밀번호와 동일합니다.",
|
||||||
"myinfo.message.validation.password3": "반각 문자 10자이내여야 합니다.",
|
"myinfo.message.validation.password3": "반각 문자 10자이내여야 합니다.",
|
||||||
|
"myinfo.message.validation.password4": "변경 비밀번호를 입력하세요.",
|
||||||
"myinfo.message.save": "비밀번호가 변경되었습니다.",
|
"myinfo.message.save": "비밀번호가 변경되었습니다.",
|
||||||
|
"myinfo.message.password.error": "비밀번호가 틀렸습니다.",
|
||||||
"login": "로그인",
|
"login": "로그인",
|
||||||
"login.id.save": "ID Save",
|
"login.id.save": "ID Save",
|
||||||
"login.id.placeholder": "아이디를 입력해주세요.",
|
"login.id.placeholder": "아이디를 입력해주세요.",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user