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