index.vue 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369
  1. <template>
  2. <div class="login-wrap">
  3. <!-- header -->
  4. <div class="login--header">
  5. <div class="login--header--l">
  6. <div class="logo">
  7. <!-- prettier-ignore -->
  8. SHOPDELI
  9. </div>
  10. </div>
  11. <div class="login--header--r"></div>
  12. </div>
  13. <!-- login -->
  14. <div class="login-box">
  15. <div class="login-l">
  16. <div class="login-l-center">
  17. <span class="logo">
  18. <!-- prettier-ignore -->
  19. SHOPDELI
  20. </span>
  21. <!-- <p>We Make Scalable Mobility Life</p> -->
  22. </div>
  23. </div>
  24. <div class="login-r">
  25. <div class="tit-login">
  26. <strong>로그인</strong>
  27. </div>
  28. <div class="login-input-wrap">
  29. <div
  30. class="txt-field-box"
  31. :class="!loginForm.validCheck.input.userId ? 'error' : ''"
  32. >
  33. <v-text-field
  34. v-model="loginForm.userId"
  35. placeholder="아이디를 입력해주세요"
  36. class="custom-input"
  37. @keyup.enter="loginAction(loginForm.userId, loginForm.passwd)"
  38. @input="setInputField('main_userId')"
  39. ></v-text-field>
  40. <i class="ico"></i>
  41. </div>
  42. <div
  43. class="txt-field-box"
  44. :class="!loginForm.validCheck.input.passwd ? 'error' : ''"
  45. >
  46. <v-text-field
  47. v-model="loginForm.passwd"
  48. :type="visible ? 'text' : 'password'"
  49. placeholder="비밀번호를 입력해주세요"
  50. class="custom-input"
  51. id="password"
  52. @keyup.enter="loginAction(loginForm.userId, loginForm.passwd)"
  53. @input="setInputField('main_passwd')"
  54. ></v-text-field>
  55. <i
  56. class="ico-eye"
  57. @click.stop="toggleVisibility"
  58. :class="visible ? 'eye-on' : 'eye-off'"
  59. ></i>
  60. <i class="ico"></i>
  61. </div>
  62. <!-- <p class="error-txt" v-if="!loginForm.validCheck.inputErrorCheck">
  63. {{ loginForm.validCheck.passwd }}
  64. </p> -->
  65. </div>
  66. <div class="login-btn-wrap">
  67. <v-btn
  68. class="custom-btn btn-blue"
  69. @keyup.enter="loginAction(loginForm.userId, loginForm.passwd)"
  70. @click="loginAction(loginForm.userId, loginForm.passwd)"
  71. >로그인</v-btn
  72. >
  73. </div>
  74. <div class="short--login--wrap">
  75. <v-btn class="btn--google" @click="onGoogleLogin"></v-btn>
  76. <v-btn class="btn--kakao"></v-btn>
  77. <v-btn class="btn--naver"></v-btn>
  78. </div>
  79. </div>
  80. </div>
  81. <!-- footer -->
  82. <div class="login-footer">
  83. <div class="login--footer--l">
  84. <p>COPYRIGHT@2018 룰렛 INC. ALL RIGHTS RESERVED.</p>
  85. <p>마포구 합정동&nbsp; |&nbsp;TEL&nbsp;02-1234-5678</p>
  86. </div>
  87. </div>
  88. </div>
  89. </template>
  90. <script setup>
  91. /************************
  92. * import
  93. ************************/
  94. //import PrivacyPop from "@/components/login/privacyPop.vue";
  95. //import AgrNPop from "@/components/terms/agreeNListPop.vue";
  96. import apiUrl from "@/composables/useApi";
  97. import QRCode from "qrcode";
  98. import { useI18n } from "vue-i18n";
  99. /************************
  100. * layout setting
  101. ************************/
  102. definePageMeta({
  103. layout: "loginlayout",
  104. });
  105. /************************
  106. * plugins inject
  107. ************************/
  108. const { $dayjs, $log, $eventBus, $toast, $userAgent } = useNuxtApp();
  109. const useStore = useDetailStore();
  110. /************************
  111. * data & created
  112. ************************/
  113. // 현재 입력 중인 필드를 설정하는 함수
  114. const setInputField = (name) => {
  115. fnValidCheck(name);
  116. };
  117. const pageId = "login";
  118. const i18n = useI18n();
  119. // 다국어
  120. let listObj = ref({
  121. langTypeList: {},
  122. });
  123. // 로그인 정보
  124. const loginForm = ref({
  125. userId: "",
  126. passwd: "",
  127. otpNum: "",
  128. username: "",
  129. authType: "GOOGLE",
  130. userAgent: "",
  131. validCheck: {
  132. input: {
  133. userId: true,
  134. passwd: true,
  135. },
  136. otp: {
  137. otpNum: true,
  138. },
  139. inputErrorCheck: true,
  140. inputValidTxt: "",
  141. otpValidTxt: "",
  142. loginValidCheck: false,
  143. btnTxt: "",
  144. btnTxtType: "",
  145. },
  146. });
  147. // 구글 OTP 1차 팝업
  148. const authPop1 = ref({
  149. popYn: false,
  150. certifyYN: false,
  151. userId: "",
  152. passwd: "",
  153. otpNum: "",
  154. validOtpKey: true,
  155. validOtpTxt: "",
  156. btnTxt: "",
  157. btnTxtType: "",
  158. applyBtn: false,
  159. succOtpYn: false,
  160. businessName: "",
  161. agreeChk1: false,
  162. agreeChk2: false,
  163. validCheck: {
  164. userId: true,
  165. passwd: true,
  166. },
  167. validTxt: "",
  168. errorCheck: false,
  169. });
  170. // 구글 OTP 2차 팝업
  171. const authPop2 = ref({
  172. popYn: false,
  173. otpNum: "",
  174. validOtpKey: true,
  175. validOtpTxt: "",
  176. errorCheck: false,
  177. });
  178. // 아이디 찾기
  179. const findId = ref({
  180. popYn: false,
  181. //tenantName: '',
  182. email: "",
  183. otpNum: "",
  184. validCheck: {
  185. input: {
  186. //tenantName: true,
  187. email: true,
  188. },
  189. otp: {
  190. otpNum: true,
  191. },
  192. inputErrorCheck: true,
  193. inputValidTxt: "",
  194. otpValidTxt: "",
  195. findIdValidCheck: false,
  196. },
  197. btnTxt: "",
  198. });
  199. // 비밀번호 초기화
  200. const resetPw = ref({
  201. popYn: false,
  202. userId: "",
  203. email: "",
  204. otpNum: "",
  205. validCheck: {
  206. input: {
  207. userId: true,
  208. email: true,
  209. },
  210. otp: {
  211. otpNum: true,
  212. },
  213. inputErrorCheck: true,
  214. inputValidTxt: "",
  215. otpValidTxt: "",
  216. resetPwValidCheck: false,
  217. },
  218. btnTxt: "",
  219. });
  220. // 초기 패스워드 변경
  221. const initPw = ref({
  222. popYn: false,
  223. passwd: "",
  224. passwd2: "",
  225. validCheck: {
  226. passwd: true,
  227. passwd2: true,
  228. },
  229. passwdCheck: false,
  230. errorTxt: "",
  231. });
  232. const selectPlaceholder = ref("");
  233. const initAuthPop1 = ref({});
  234. const initAuthPop2 = ref({});
  235. const initFindId = ref({});
  236. const initResetPw = ref({});
  237. const initInitPw = ref({});
  238. const googleOtpQrCode = ref("");
  239. const googleOtpSecretKey = ref("");
  240. const loginInfo = ref({});
  241. const checkbox = ref(false);
  242. const langType = ref("");
  243. const toggleVisibility = () => {
  244. visible.value = !visible.value;
  245. };
  246. const visible = ref(false);
  247. const isAgrNPop = ref(false);
  248. const isShowAgrNPop = ref(false);
  249. let saveId = localStorage.getItem("saveId");
  250. if (saveId) {
  251. checkbox.value = true;
  252. loginForm.value.userId = saveId;
  253. }
  254. // 개인정보처리방침 이용약관 팝업
  255. //const privacyPop = ref(false);
  256. const privacyDetail = ref({
  257. kr: {
  258. title: "",
  259. contents: "",
  260. },
  261. en: {
  262. title: "",
  263. contents: "",
  264. },
  265. });
  266. const systemInfo = ref({
  267. mode: "",
  268. });
  269. const loginAction = (__ID, __PASS) => {
  270. let _req = {
  271. id: __ID,
  272. password: __PASS,
  273. };
  274. useAxios()
  275. .post("/roulette/login", _req)
  276. .then((res) => {
  277. if (res.data) {
  278. // console.log(res.data);
  279. useAuthStore().setAuth(res.data);
  280. useAuthStore().setAccessToken(res.data.accessToken);
  281. useAuthStore().setRefreshToken(res.data.refreshToken);
  282. localStorage.setItem("tempAccess", __ID);
  283. useUtil.setPageMove("/view/event/evtList");
  284. useStore.menuInfo.menuIndex = "0";
  285. useStore.menuInfo.menuId = "menu02";
  286. useStore.menuInfo.pageRtName = "이벤트 관리";
  287. useStore.menuInfo.pageStatus = null;
  288. }
  289. })
  290. .catch((error) => {
  291. if (error.response) {
  292. console.log("status:", error.response.status, "data:", error.response.data);
  293. // 안전하게 errCode, message 접근
  294. const errData = error.response.data || {};
  295. const errCode = errData.errCode || errData.errorCode || errData.code || "";
  296. const errMsg = errData.message || "알 수 없는 오류가 발생했습니다.";
  297. console.log("errCode:", errCode, "message:", errMsg);
  298. } else {
  299. console.log("error:", error.message, error.code);
  300. }
  301. if (error.response?.status) {
  302. fnLoginSet(error.response.data.messages.message);
  303. }
  304. $log.debug("[login][fnIdPwCheck][error]");
  305. })
  306. .finally(() => {
  307. $log.debug("[login][fnIdPwCheck][finished]");
  308. });
  309. };
  310. // onMounted
  311. onMounted(() => {
  312. function handleMessage(event) {
  313. // 개발환경이면 아래처럼 확인
  314. if (
  315. event.origin === "http://0.0.0.0:3000" ||
  316. event.origin === "http://localhost:3000"
  317. ) {
  318. const { accessToken, refreshToken, user } = event.data;
  319. // 토큰 저장 등 필요한 처리 로직
  320. console.log(accessToken);
  321. console.log(refreshToken);
  322. console.log(user);
  323. //useAuthStore().setAuth(res.data);
  324. useAuthStore().setAccessToken(accessToken);
  325. useAuthStore().setRefreshToken(refreshToken);
  326. //localStorage.setItem("tempAccess", __ID);
  327. useUtil.setPageMove("/view/event/evtList");
  328. useStore.menuInfo.menuIndex = "0";
  329. useStore.menuInfo.menuId = "menu02";
  330. useStore.menuInfo.pageRtName = "이벤트 관리";
  331. useStore.menuInfo.pageStatus = null;
  332. }
  333. }
  334. window.addEventListener("message", handleMessage);
  335. onBeforeUnmount(() => window.removeEventListener("message", handleMessage));
  336. });
  337. watchEffect(() => {
  338. // 감시하고자 하는 데이터를 해당 블럭내에서 사용하면 호출된다.
  339. // getLang.value를 감시하는 상태
  340. fnGetEnumCode(useLangStore().getLang);
  341. });
  342. $eventBus.off("SET_SUCCESS_POPUP");
  343. $eventBus.on("SET_SUCCESS_POPUP", () => {
  344. // 안내 팝업 확인 클릭 팝업 초기화처리
  345. fnOtpPopClose("findId");
  346. fnOtpPopClose("resetPw");
  347. });
  348. $eventBus.off("PASSWD_CHANGE");
  349. $eventBus.on("PASSWD_CHANGE", () => {
  350. fnPasswdChange();
  351. });
  352. $eventBus.off("INIT_PASSWORD");
  353. $eventBus.on("INIT_PASSWORD", () => {
  354. initPw.value.popYn = true;
  355. });
  356. $eventBus.off("SET_LOGIN");
  357. $eventBus.on("SET_LOGIN", () => {
  358. fnLogin();
  359. });
  360. /************************
  361. * Methods
  362. ************************/
  363. // created
  364. loginForm.value.btnTxtType = "S";
  365. authPop1.value.btnTxtType = "S";
  366. loginForm.value.btnTxt = i18n.t("login.authNumSend");
  367. authPop1.value.btnTxt = i18n.t("common.sendAuthNumber");
  368. findId.value.btnTxt = i18n.t("common.sendAuthNumber");
  369. resetPw.value.btnTxt = i18n.t("common.sendAuthNumber");
  370. initAuthPop1.value = _cloneDeep(authPop1.value);
  371. initAuthPop2.value = _cloneDeep(authPop2.value);
  372. initFindId.value = _cloneDeep(findId.value);
  373. initResetPw.value = _cloneDeep(resetPw.value);
  374. initInitPw.value = _cloneDeep(initPw.value);
  375. /**
  376. * @SCRIPT
  377. * 다국어 기능 | 한글 영문 변경 이벤트
  378. */
  379. function fnLangChange() {
  380. useLangStore().setLang(langType.value);
  381. }
  382. function fnGetEnumCode(lang) {
  383. lang = useUtil.nvl(lang, "kr");
  384. langType.value = lang;
  385. let objEnum = useEnumCode.getEnumCode(lang);
  386. listObj.value.langTypeList = objEnum.langType;
  387. i18n.locale.value = lang;
  388. }
  389. /**
  390. * @SCRIPT
  391. * 라디오버튼 변경 이벤트 (버튼별 문구)
  392. */
  393. function fnChangeAuth() {
  394. if (loginForm.value.authType === "GOOGLE") {
  395. selectPlaceholder.value = i18n.t("login.googleOTPNum");
  396. } else if (loginForm.value.authType === "EMAIL") {
  397. selectPlaceholder.value = i18n.t("login.emailAuthNum");
  398. } else {
  399. selectPlaceholder.value = i18n.t("login.smsAuthNum");
  400. }
  401. loginForm.value.btnTxt = i18n.t("login.authNumSend");
  402. loginForm.value.btnTxtType = "S";
  403. if (!loginForm.value.validCheck.otp.otpNum) {
  404. fnValidCheck("main_otpNum");
  405. }
  406. }
  407. /**
  408. * @SCRIPT
  409. * 구글OTP 인증 버튼 클릭 이벤트
  410. * @param {*} type
  411. */
  412. function fnAuthCheck(type) {
  413. let issuer = ""; // 회사명
  414. let account = ""; // 아이디
  415. let otpUrl = ""; // 큐알코드 생성 URL
  416. let _req = {
  417. username: authPop1.value.userId,
  418. password: btoa(authPop1.value.passwd),
  419. mfaType: "SMS",
  420. otpNum: authPop1.value.otpNum,
  421. };
  422. if (type === "optApply1") {
  423. fnValidCheck("createOtp_userId");
  424. fnValidCheck("createOtp_passwd");
  425. if (authPop1.value.errorCheck) {
  426. fnAuth("POPUP");
  427. }
  428. } else if (type === "optApply2") {
  429. //OTP 인증 팝업2
  430. useAxios()
  431. .post(apiUrl.googleSecretKey, _req)
  432. .then((res) => {
  433. googleOtpSecretKey.value = res.data.data.secretKey;
  434. // 시크릿 키를 이용한 큐알코드 생성
  435. issuer = "[P5G]" + authPop1.value.businessName;
  436. account = authPop1.value.userId;
  437. otpUrl =
  438. "otpauth://totp/" +
  439. encodeURIComponent(issuer + ":" + account).replace(/\+/g, "%20") +
  440. "?secret=" +
  441. encodeURIComponent(googleOtpSecretKey.value).replace(/\+/g, "%20") +
  442. "&issuer=" +
  443. encodeURIComponent(issuer).replace(/\+/g, "%20");
  444. fnCreateQrCode(otpUrl);
  445. $toast.success("인증처리가 완료되었습니다.");
  446. authPop1.value.applyBtn = false;
  447. authPop1.value.agreeChk1 = true;
  448. authPop1.value.succOtpYn = true;
  449. $log.debug("[login][fnAuthCheck][success]");
  450. })
  451. .catch((error) => {
  452. $log.debug("[login][fnAuthCheck][error]");
  453. let errorData = error.response.data;
  454. errorData.type = "fnAuthCheck";
  455. fnLoginFail(errorData);
  456. })
  457. .finally(() => {
  458. $log.debug("[login][fnAuthCheck][finished]");
  459. });
  460. } else if (type === "optApply2Yn") {
  461. authPop1.value.popYn = false;
  462. authPop2.value.popYn = true;
  463. } else if (type === "findId") {
  464. //fnValidCheck('findId_tenantName')
  465. fnValidCheck("findId_email");
  466. if (findId.value.validCheck.inputErrorCheck) {
  467. fnIdPwCheck(type);
  468. }
  469. } else if (type === "resetPw") {
  470. fnValidCheck("resetPw_userId");
  471. fnValidCheck("resetPw_email");
  472. if (resetPw.value.validCheck.inputErrorCheck) {
  473. fnIdPwCheck(type);
  474. }
  475. } else if (type === "createOtp_otpNum") {
  476. // 구글OTP등록화면에서 인증번호 받기
  477. fnAuthSend(authPop1.value.btnTxtType, "createOtp_otpNum");
  478. } else {
  479. fnValidCheck("main_userId");
  480. fnValidCheck("main_passwd");
  481. if (loginForm.value.validCheck.inputErrorCheck) {
  482. fnAuth(type);
  483. }
  484. }
  485. }
  486. /**
  487. * @SCRIPT
  488. * 큐알코드 생성
  489. * @param {*} otpUrl
  490. */
  491. async function fnCreateQrCode(otpUrl) {
  492. googleOtpQrCode.value = await QRCode.toDataURL(otpUrl);
  493. }
  494. /**
  495. * @SCRIPT
  496. * 로그인 실패관련 토스트 & confirm 처리
  497. */
  498. function fnLoginFail(dataObj) {
  499. let errorMessage = "";
  500. let type = dataObj.type;
  501. if (dataObj.code === "2001" || dataObj.code === "2002") {
  502. let valieTxt = "";
  503. if (!useUtil.isNull(dataObj.reason)) {
  504. if (dataObj.reason < "4") {
  505. valieTxt += i18n.t("login.valid.isNullPw");
  506. } else {
  507. // 4회 이상 비밀번호 실패
  508. fnLoginFailConfirm(dataObj);
  509. }
  510. } else {
  511. valieTxt += i18n.t("login.valid.isNullId");
  512. }
  513. console.log("비밀번호 초기화 팝업:::" + resetPw.value.popYn);
  514. console.log("아이디찾기 팝업:::" + findId.value.popYn);
  515. console.log("OTP생성 팝업:::" + authPop1.value.popYn);
  516. if (resetPw.value.popYn) {
  517. resetPw.value.validCheck.inputErrorCheck = false;
  518. resetPw.value.validCheck.inputValidTxt = valieTxt;
  519. } else if (findId.value.popYn) {
  520. findId.value.validCheck.inputErrorCheck = false;
  521. findId.value.validCheck.inputValidTxt = valieTxt;
  522. } else if (authPop1.value.popYn) {
  523. authPop1.value.errorCheck = false;
  524. authPop1.value.validTxt = valieTxt;
  525. } else {
  526. loginForm.value.validCheck.inputErrorCheck = false;
  527. loginForm.value.validCheck.inputValidTxt = valieTxt;
  528. }
  529. } else if (dataObj.code === "2003") {
  530. let otpTxt = "";
  531. if (loginForm.value.authType === "GOOGLE") {
  532. otpTxt += i18n.t("login.valid.isNullOtp");
  533. } else if (loginForm.value.authType === "EMAIL") {
  534. otpTxt += i18n.t("login.valid.isNullEmail");
  535. } else {
  536. otpTxt += i18n.t("login.valid.isNullSms");
  537. }
  538. if (resetPw.value.popYn) {
  539. resetPw.value.validCheck.otp.otpNum = false;
  540. resetPw.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullEmail");
  541. } else if (findId.value.popYn) {
  542. findId.value.validCheck.otp.otpNum = false;
  543. findId.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullEmail");
  544. } else if (authPop1.value.popYn) {
  545. authPop1.value.validOtpKey = false;
  546. authPop1.value.validOtpTxt = i18n.t("login.valid.isNullSms");
  547. } else {
  548. loginForm.value.validCheck.otp.otpNum = false;
  549. loginForm.value.validCheck.otpValidTxt = otpTxt;
  550. }
  551. } else if (
  552. dataObj.code === "2004" ||
  553. dataObj.code === "2005" ||
  554. dataObj.code === "2006" ||
  555. dataObj.code === "2007" ||
  556. dataObj.code === "2010"
  557. ) {
  558. // 2004: 접속허용IP아님 , 2005: 사업자 접속불가 상태, 2006: 사업자 계약 만료, 2007: 접속 계정 수 초과, 2010: 계정 잠김 (비밀번호 틀림 N 회) 5회 이상 비밀번호 실패
  559. fnLoginFailConfirm(dataObj);
  560. }
  561. if (!useUtil.isNull(errorMessage)) {
  562. // 토스트 함수 (success, info, error, warn, dark)
  563. if (type === "findId" || type === "resetPw")
  564. errorMessage += i18n.t("login.failMessage.2001");
  565. else errorMessage += i18n.t("login.valid.isNull");
  566. nextTick().then(() => {
  567. $toast.error(errorMessage);
  568. });
  569. }
  570. }
  571. /**
  572. * @SCRIPT
  573. * 로그인 실패관련 토스트 & confirm 처리
  574. */
  575. function fnLoginFailConfirm(dataObj) {
  576. let confirmMessage = "";
  577. if (dataObj.code === "2002") confirmMessage = i18n.t("login.failMessage.2002");
  578. else if (dataObj.code === "2004") confirmMessage = i18n.t("login.failMessage.2004");
  579. else if (dataObj.code === "2005") confirmMessage = i18n.t("login.failMessage.2005");
  580. else if (dataObj.code === "2006") confirmMessage = i18n.t("login.failMessage.2006");
  581. else if (dataObj.code === "2007") confirmMessage = i18n.t("login.failMessage.2007");
  582. else if (dataObj.code === "2010") confirmMessage = i18n.t("login.failMessage.2010");
  583. let param = {
  584. id: pageId,
  585. title: i18n.t("common.popTitle"),
  586. content: confirmMessage,
  587. yes: {
  588. text: i18n.t("common.confirm"),
  589. isProc: true,
  590. event: "",
  591. param: {},
  592. },
  593. };
  594. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  595. }
  596. /**
  597. * @SCRIPT
  598. * 아이디 저장 체크 이벤트
  599. */
  600. function fnSaveId() {
  601. if (checkbox.value) {
  602. // 체크 시 저장
  603. localStorage.setItem("saveId", loginForm.value.userId);
  604. } else {
  605. // 미체크 시 삭제
  606. localStorage.removeItem("saveId");
  607. }
  608. }
  609. /**
  610. * @API
  611. * 아이디 찾기에서 사업자명 & 이메일 주소 체크 API
  612. * 비밀번호 초기화에서 사용자계정 & 이메일 주소 체크 API
  613. */
  614. function fnIdPwCheck(type) {
  615. let _req = {};
  616. if (type === "findId") {
  617. //_req.tenantName = findId.value.tenantName,
  618. _req.email = findId.value.email;
  619. } else {
  620. (_req.accountId = resetPw.value.userId), (_req.email = resetPw.value.email);
  621. }
  622. useAxios()
  623. .post(apiUrl.findCheck, _req)
  624. .then((res) => {
  625. if (type === "findId") {
  626. findId.value.btnTxt = i18n.t("common.sendReAuthNumber");
  627. } else {
  628. resetPw.value.btnTxt = i18n.t("common.sendReAuthNumber");
  629. }
  630. $toast.success(i18n.t("login.sendEmail"));
  631. $log.debug("[login][fnIdPwCheck][success]");
  632. })
  633. .catch((error) => {
  634. let errorData = error.response.data;
  635. errorData.type = type;
  636. fnLoginFail(errorData);
  637. $log.debug("[login][fnIdPwCheck][error]");
  638. })
  639. .finally(() => {
  640. $log.debug("[login][fnIdPwCheck][finished]");
  641. });
  642. }
  643. /**
  644. * @API
  645. * 가입된 아이디 비밀번호 체크 API
  646. */
  647. function fnAuth(type) {
  648. let _req = {};
  649. if (type === "POPUP") {
  650. _req.username = authPop1.value.userId;
  651. _req.password = btoa(authPop1.value.passwd);
  652. } else {
  653. _req.username = loginForm.value.userId;
  654. _req.password = btoa(loginForm.value.passwd);
  655. }
  656. // 아이디&비밀번호 validation체크 정상일 경우 아이디 비밀번호를 체크 하는 API를 진행한다.
  657. useAxios()
  658. .post(apiUrl.idPwCheck, _req)
  659. .then((res) => {
  660. if (type === "GOOGLE") {
  661. fnLogin();
  662. } else if (type === "POPUP") {
  663. // if(useUtil.isNull(res.data.data.tenantName)) {
  664. // authPop1.value.businessName = ''
  665. // } else {
  666. // authPop1.value.businessName = res.data.data.tenantName
  667. // }
  668. // 아이디 비밀번호 입력 영역 비활성화
  669. authPop1.value.certifyYN = true;
  670. //authPop1.value.agreeChk1 = true
  671. } else {
  672. // 아이디&비밀번호가 존재하여 이메일 발송을 진행합니다.
  673. fnAuthSend(loginForm.value.btnTxtType, "loginForm");
  674. }
  675. $log.debug("[login][fnAuth][success]");
  676. })
  677. .catch((error) => {
  678. let errorData = error.response.data;
  679. errorData.type = type;
  680. fnLoginFail(errorData);
  681. $log.debug("[login][fnAuth][error]");
  682. })
  683. .finally(() => {
  684. $log.debug("[login][fnAuth][finished]");
  685. });
  686. }
  687. /**
  688. * @API
  689. * 가입된 아이디 비밀번호 체크가 정상 일 경우 인증번호 발송
  690. * 이메일(EMAIL) & 문자(SMS)
  691. */
  692. function fnAuthSend(type, form) {
  693. let _req = {};
  694. if (form === "loginForm") {
  695. (_req.username = loginForm.value.userId),
  696. (_req.password = btoa(loginForm.value.passwd)),
  697. (_req.mfaType = loginForm.value.authType);
  698. } else {
  699. (_req.username = authPop1.value.userId),
  700. (_req.password = btoa(authPop1.value.passwd)),
  701. (_req.mfaType = "SMS");
  702. }
  703. useAxios()
  704. .post(apiUrl.otpSend, _req)
  705. .then((res) => {
  706. if (form === "loginForm") {
  707. loginForm.value.btnTxt = i18n.t("login.authNumReSend");
  708. loginForm.value.btnTxtType = "R";
  709. } else {
  710. authPop1.value.btnTxt = i18n.t("login.authNumReSend");
  711. authPop1.value.btnTxtType = "R";
  712. }
  713. if (type === "S") {
  714. if (form === "loginForm") {
  715. if (loginForm.value.authType === "EMAIL") {
  716. $toast.success(i18n.t("login.sendEmail"));
  717. } else {
  718. $toast.success(i18n.t("login.sendSms"));
  719. }
  720. } else {
  721. $toast.success(i18n.t("login.sendSms"));
  722. }
  723. } else {
  724. if (form === "loginForm") {
  725. if (loginForm.value.authType === "EMAIL") {
  726. $toast.success(i18n.t("login.sendReEmail"));
  727. } else {
  728. $toast.success(i18n.t("login.sendReSms"));
  729. }
  730. } else {
  731. $toast.success(i18n.t("login.sendReSms"));
  732. }
  733. }
  734. $log.debug("[login][fnAuthSend][success]");
  735. })
  736. .catch((error) => {
  737. $log.debug("[login][fnAuthSend][error]");
  738. // 에러 메시지 체크 팝업으로 변경
  739. let param = {
  740. id: pageId,
  741. title: i18n.t("common.popTitle"),
  742. content: i18n.t("login.sendFail"),
  743. yes: {
  744. text: i18n.t("common.confirm"),
  745. isProc: true,
  746. event: "",
  747. param: {},
  748. },
  749. };
  750. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  751. // let errorMessage = i18n.t('login.sendFail')
  752. // errorMessage += error.response.data.message
  753. // $toast.error(errorMessage)
  754. })
  755. .finally(() => {
  756. $log.debug("[login][fnAuthSend][finished]");
  757. });
  758. }
  759. const fnLoginSet = (__MSG) => {
  760. let param = {
  761. id: pageId,
  762. title: "로그인",
  763. content: __MSG,
  764. yes: {
  765. text: "확인",
  766. isProc: true,
  767. event: "FN_LOGIN",
  768. param: "",
  769. },
  770. no: {
  771. text: "취소",
  772. isProc: false,
  773. },
  774. };
  775. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  776. };
  777. // 구글 로그인 버튼 클릭 시 호출
  778. function onGoogleLogin() {
  779. const clientId =
  780. "373780605211-diojebh7mug45urv9rnqdil6n0b1ogge.apps.googleusercontent.com"; // 실제 클라이언트 ID로 교체
  781. const redirectUri = "https://shopdeli.mycafe24.com/auth/callback"; // 실제 리디렉션 URI로 교체
  782. const scope = "openid email profile";
  783. const responseType = "code"; // 또는 'code' (백엔드 연동 시)
  784. const state = Math.random().toString(36).substring(2);
  785. const googleAuthUrl = `https://accounts.google.com/o/oauth2/v2/auth?client_id=${clientId}&redirect_uri=${encodeURIComponent(
  786. redirectUri
  787. )}&response_type=${responseType}&scope=${encodeURIComponent(scope)}&state=${state}`;
  788. const width = 500;
  789. const height = 600;
  790. const dualScreenLeft =
  791. window.screenLeft !== undefined ? window.screenLeft : window.screenX;
  792. const dualScreenTop =
  793. window.screenTop !== undefined ? window.screenTop : window.screenY;
  794. const currentWidth = window.innerWidth
  795. ? window.innerWidth
  796. : document.documentElement.clientWidth
  797. ? document.documentElement.clientWidth
  798. : screen.width;
  799. const currentHeight = window.innerHeight
  800. ? window.innerHeight
  801. : document.documentElement.clientHeight
  802. ? document.documentElement.clientHeight
  803. : screen.height;
  804. const left = dualScreenLeft + (currentWidth - width) / 2;
  805. const top = dualScreenTop + (currentHeight - height) / 2;
  806. window.open(
  807. googleAuthUrl,
  808. "googleLogin",
  809. `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
  810. );
  811. }
  812. /**
  813. * @API
  814. * 최종 로그인 버튼 클릭 시 API
  815. */
  816. function fnLogin(__USERID, __USERPASS) {
  817. // 파라미터 전달 값 [아이디, 비밀번호, otpNum, 브라우저정보]
  818. //userId: loginForm.value.userId,
  819. // let _req = {
  820. // username: loginForm.value.userId,
  821. // password: btoa(loginForm.value.passwd),
  822. // };
  823. localStorage.setItem("tempAccess", __USERID);
  824. if (__USERID == "admin" && __USERPASS == "1234") {
  825. useUtil.setPageMove("/view/media/newsList");
  826. } else {
  827. fnLoginSet("비밀번호가 맞지 않습니다. 확인해주세요.");
  828. }
  829. // useAxios()
  830. // .post(apiUrl.otpCheck, _req)
  831. // .then((res) => {
  832. // loginInfo.value = res.data.data;
  833. // useAuthStore().setAccessToken(loginInfo.value.accessToken);
  834. // useAuthStore().setRefreshToken(loginInfo.value.refreshToken);
  835. // // OTP key체크 성공 후 개인정보에 대한 API를 호출 한다.
  836. // fnServiceModeCheck();
  837. // $log.debug("[login][fnLogin][success]");
  838. // })
  839. // .catch((error) => {
  840. // $log.debug("[login][fnLogin][error]");
  841. // let errorData = error.response.data;
  842. // errorData.type = "fnLogin";
  843. // fnLoginFail(errorData);
  844. // })
  845. // .finally(() => {
  846. // $log.debug("[login][fnLogin][finished]");
  847. // });
  848. }
  849. /**
  850. * @API
  851. * 최종 로그인 전 점검공지에 대한 정보를 가져온다.
  852. */
  853. function fnServiceModeCheck() {
  854. useAxios()
  855. .get(useApi.getServiceMode)
  856. .then((res) => {
  857. $log.debug("[login][fnServiceModeCheck][success]");
  858. let data = res.data.data;
  859. systemInfo.value.mode = data.mode;
  860. fnMyInfo();
  861. })
  862. .catch((error) => {
  863. $log.debug("[login][fnServiceModeCheck][error]");
  864. useErrorHandler().fnSetCommErrorHandle(error);
  865. })
  866. .finally(() => {
  867. $log.debug("[login][fnServiceModeCheck][finished]");
  868. });
  869. }
  870. /**
  871. * @API
  872. * 최종 로그인 버튼 클릭 후 성공 시 토큰값을 통해 개인정보 API 호출
  873. */
  874. function fnMyInfo() {
  875. useAxios()
  876. .get(apiUrl.myInfo)
  877. .then((res) => {
  878. let dataObj = {};
  879. dataObj = res.data.data;
  880. dataObj.accessToken = useAuthStore().getAccessToken;
  881. dataObj.refreshToken = useAuthStore().getRefreshToken;
  882. useAuthStore().setServiceMode(systemInfo.value.mode);
  883. useAuthStore().setAuth(dataObj);
  884. // 아이디 저장 여부 체크
  885. fnSaveId();
  886. let accountValue = useAuthStore().getAccountRole.charAt(0).toUpperCase();
  887. // 첫화면 redirect_page URL로 설정
  888. // 초기 비밀번호 사용
  889. if (useAuthStore().getFirstLoginYn === "Y") {
  890. // 최초로그인
  891. initPw.value.popYn = true;
  892. } else if (useAuthStore().getPwExpiredYN === "Y") {
  893. // 비밀번호 3개월 만료
  894. let param = {
  895. id: pageId,
  896. title: i18n.t("common.popTitle"),
  897. content: i18n.t("login.failMessage.2009"),
  898. yes: {
  899. text: i18n.t("common.confirm"),
  900. isProc: true,
  901. event: "INIT_PASSWORD", // 확인 클릭 시 비밀번호 변경 팝업 활성화
  902. param: {},
  903. },
  904. no: {
  905. text: i18n.t("common.skip"),
  906. isProc: true,
  907. event: "SET_LOGIN", // 건너뛰기 클릭 시 로그인 처리
  908. param: {},
  909. },
  910. };
  911. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  912. } else if (useAuthStore().getTermsArgYN === "N") {
  913. // 필수약관동의여부
  914. isShowAgrNPop.value = true;
  915. nextTick().then(() => {
  916. isAgrNPop.value = true;
  917. });
  918. } else {
  919. if (systemInfo.value.mode === "INACTIVE") {
  920. // 점검모드일 경우 점검모드 페이지로 이동
  921. if (accountValue === "S") {
  922. useUtil.setPageMove("/view/home/dashboard");
  923. } else {
  924. useUtil.setPageMove("/view/home/serviceMode");
  925. }
  926. } else {
  927. if (accountValue === "A" || accountValue === "S") {
  928. useUtil.setPageMove("/view/home/dashboard");
  929. } else {
  930. useUtil.setPageMove("/view/home/tenantDashboard");
  931. }
  932. }
  933. }
  934. $log.debug("[login][fnMyInfo][success]");
  935. })
  936. .catch((error) => {
  937. $log.debug("[login][fnMyInfo][error]");
  938. useErrorHandler().fnSetCommErrorHandle(error);
  939. })
  940. .finally(() => {
  941. $log.debug("[login][fnMyInfo][finished]");
  942. });
  943. }
  944. /**
  945. * @API
  946. * 최초 비밀번호 변경 API 호출
  947. */
  948. function fnPasswdChange() {
  949. let _req = {
  950. newPassword: btoa(initPw.value.passwd2),
  951. };
  952. useAxios()
  953. .post(apiUrl.myInfoUpdate, _req)
  954. .then((res) => {
  955. localStorage.removeItem("authStore");
  956. // 세션 초기화 및 로그인 화면 이동
  957. useUtil.setPageMove("/");
  958. $log.debug("[login][fnPasswdChange][success]");
  959. })
  960. .catch((error) => {
  961. $log.debug("[login][fnPasswdChange][error]");
  962. let errorData = error.response.data;
  963. errorData.type = "fnPasswdChange";
  964. fnLoginFail(errorData);
  965. })
  966. .finally(() => {
  967. $log.debug("[login][fnPasswdChange][finished]");
  968. });
  969. }
  970. /**
  971. * @API
  972. * 로그인 FOOTER 약관 조회 API
  973. */
  974. function fnPrivacy(type) {
  975. let _req = {
  976. termsType: useUtil.nvl(type, null),
  977. };
  978. useAxios()
  979. .get(apiUrl.loginTerms, { params: _req })
  980. .then((res) => {
  981. let dataObj = res.data.data;
  982. privacyDetail.value.kr.title = dataObj.termsTitle;
  983. privacyDetail.value.kr.contents = dataObj.termsCont;
  984. privacyDetail.value.en.title = dataObj.termsTitleEn;
  985. privacyDetail.value.en.contents = dataObj.termsContEn;
  986. privacyPop.value = true;
  987. })
  988. .catch((error) => {
  989. $log.debug("[login][fnPrivacy][error]");
  990. useErrorHandler().fnSetCommErrorHandle(error, fnPrivacy);
  991. })
  992. .finally(() => {
  993. $log.debug("[login][fnPrivacy][finished]");
  994. });
  995. }
  996. /**
  997. * @SCRIPT
  998. * 아이디 & 비밀번호 & otp 값의 유효성 검사 체크 및 로그인 버튼 활성화 이벤트
  999. */
  1000. function fnValidCheck(input) {
  1001. if (_includes(input, "main_")) {
  1002. let commonValidCheck = {
  1003. inputCheck: false,
  1004. otpCheck: false,
  1005. };
  1006. if (input === "main_userId") {
  1007. if (
  1008. useUtil.isNull(loginForm.value.userId) ||
  1009. !/^[a-zA-Z0-9._-]{1,20}$/.test(loginForm.value.userId)
  1010. ) {
  1011. loginForm.value.validCheck.input.userId = false;
  1012. loginForm.value.validCheck.inputValidTxt = i18n.t("login.valid.isNull");
  1013. } else {
  1014. loginForm.value.validCheck.input.userId = true;
  1015. if (!useUtil.isNull(loginForm.value.passwd)) {
  1016. fnValidCheck("main_passwd");
  1017. }
  1018. }
  1019. } else if (input === "main_passwd") {
  1020. if (
  1021. useUtil.isNull(loginForm.value.passwd) ||
  1022. !/^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{8,30}$/i.test(
  1023. loginForm.value.passwd
  1024. )
  1025. ) {
  1026. //if(useUtil.isNull(loginForm.value.passwd)) {
  1027. loginForm.value.validCheck.input.passwd = false;
  1028. loginForm.value.validCheck.inputValidTxt = i18n.t("login.valid.isNull");
  1029. } else {
  1030. loginForm.value.validCheck.input.passwd = true;
  1031. }
  1032. } else if (input === "main_otpNum") {
  1033. loginForm.value.otpNum = useValid.p5gNumCheck(loginForm.value.otpNum, "otp");
  1034. if (
  1035. useUtil.isNull(loginForm.value.otpNum) ||
  1036. loginForm.value.otpNum.length <= 5
  1037. ) {
  1038. loginForm.value.validCheck.otp.otpNum = false;
  1039. if (loginForm.value.authType === "GOOGLE") {
  1040. loginForm.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullOtp");
  1041. } else if (loginForm.value.authType === "EMAIL") {
  1042. loginForm.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullEmail");
  1043. } else {
  1044. loginForm.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullSms");
  1045. }
  1046. } else {
  1047. loginForm.value.validCheck.otp.otpNum = true;
  1048. }
  1049. }
  1050. loginForm.value.validCheck.inputErrorCheck = _every(
  1051. loginForm.value.validCheck.input,
  1052. (value) => value === true
  1053. );
  1054. // 전체 항목에 대한 validation이 정상일 경우 login버튼 활성화
  1055. if (
  1056. !useUtil.isNull(loginForm.value.userId) &&
  1057. !useUtil.isNull(loginForm.value.passwd) &&
  1058. !useUtil.isNull(loginForm.value.otpNum)
  1059. ) {
  1060. commonValidCheck.inputCheck = _every(
  1061. loginForm.value.validCheck.input,
  1062. (value) => value === true
  1063. );
  1064. commonValidCheck.otpCheck = _every(
  1065. loginForm.value.validCheck.otp,
  1066. (value) => value === true
  1067. );
  1068. }
  1069. loginForm.value.validCheck.loginValidCheck = _every(
  1070. commonValidCheck,
  1071. (value) => value === true
  1072. );
  1073. } else if (_includes(input, "createOtp_")) {
  1074. if (input === "createOtp_userId") {
  1075. if (
  1076. useUtil.isNull(authPop1.value.userId) ||
  1077. !/^[a-zA-Z0-9._-]{1,20}$/.test(authPop1.value.userId)
  1078. ) {
  1079. authPop1.value.validCheck.userId = false;
  1080. authPop1.value.validTxt = i18n.t("login.valid.isNull");
  1081. } else {
  1082. authPop1.value.validCheck.userId = true;
  1083. if (!useUtil.isNull(authPop1.value.passwd)) {
  1084. fnValidCheck("createOtp_passwd");
  1085. }
  1086. }
  1087. } else if (input === "createOtp_passwd") {
  1088. if (
  1089. useUtil.isNull(authPop1.value.passwd) ||
  1090. !/^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{8,30}$/i.test(
  1091. authPop1.value.passwd
  1092. )
  1093. ) {
  1094. //if(useUtil.isNull(authPop1.value.passwd)) {
  1095. authPop1.value.validCheck.passwd = false;
  1096. authPop1.value.validTxt = i18n.t("login.valid.isNull");
  1097. } else {
  1098. authPop1.value.validCheck.passwd = true;
  1099. }
  1100. } else if (input === "createOtp_otpNum1") {
  1101. authPop1.value.otpNum = useValid.p5gNumCheck(authPop1.value.otpNum, "otp");
  1102. if (useUtil.isNull(authPop1.value.otpNum) || authPop1.value.otpNum.length <= 5) {
  1103. authPop1.value.validOtpKey = false;
  1104. authPop1.value.errorCheck = false;
  1105. authPop1.value.validOtpTxt = i18n.t("login.valid.isNullSms");
  1106. } else {
  1107. authPop1.value.validOtpKey = true;
  1108. authPop1.value.errorCheck = true;
  1109. authPop1.value.applyBtn = true;
  1110. }
  1111. } else if (input === "createOtp_otpNum") {
  1112. authPop2.value.otpNum = useValid.p5gNumCheck(authPop2.value.otpNum, "otp");
  1113. if (useUtil.isNull(authPop2.value.otpNum) || authPop2.value.otpNum.length <= 5) {
  1114. authPop2.value.validOtpKey = false;
  1115. authPop2.value.errorCheck = false;
  1116. if (loginForm.value.authType === "GOOGLE") {
  1117. authPop2.value.validOtpTxt = i18n.t("login.valid.isNullOtp");
  1118. } else if (loginForm.value.authType === "EMAIL") {
  1119. authPop2.value.validOtpTxt = i18n.t("login.valid.isNullEmail");
  1120. } else {
  1121. authPop2.value.validOtpTxt = i18n.t("login.valid.isNullSms");
  1122. }
  1123. } else {
  1124. authPop2.value.validOtpKey = true;
  1125. authPop2.value.errorCheck = true;
  1126. }
  1127. }
  1128. authPop1.value.errorCheck = _every(
  1129. authPop1.value.validCheck,
  1130. (value) => value === true
  1131. );
  1132. } else if (_includes(input, "findId_")) {
  1133. let validAllCheck = {
  1134. inputCheck: false,
  1135. otpCheck: false,
  1136. };
  1137. // if(input === 'findId_tenantName') {
  1138. // if(useUtil.isNull(findId.value.tenantName)) {
  1139. // findId.value.validCheck.input.tenantName = false
  1140. // findId.value.validCheck.inputValidTxt = i18n.t('login.findId.valid.isNullTenantName')
  1141. // } else {
  1142. // findId.value.validCheck.input.tenantName = true
  1143. // if(!useUtil.isNull(findId.value.email)) {
  1144. // fnValidCheck('findId_email')
  1145. // }
  1146. // }
  1147. // } else
  1148. if (input === "findId_email") {
  1149. if (useUtil.isNull(findId.value.email)) {
  1150. findId.value.validCheck.input.email = false;
  1151. findId.value.validCheck.inputValidTxt = i18n.t(
  1152. "login.findId.valid.isNullEmail"
  1153. );
  1154. } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(findId.value.email)) {
  1155. findId.value.validCheck.input.email = false;
  1156. findId.value.validCheck.inputValidTxt = i18n.t(
  1157. "login.findId.valid.isTypeEmail"
  1158. );
  1159. } else {
  1160. findId.value.validCheck.input.email = true;
  1161. }
  1162. } else if (input === "findId_otpNum") {
  1163. findId.value.otpNum = useValid.p5gNumCheck(findId.value.otpNum, "otp");
  1164. if (useUtil.isNull(findId.value.otpNum) || findId.value.otpNum.length <= 5) {
  1165. findId.value.validCheck.otp.otpNum = false;
  1166. findId.value.validCheck.otpValidTxt = i18n.t("login.findId.valid.isNullOtp");
  1167. } else {
  1168. findId.value.validCheck.otp.otpNum = true;
  1169. }
  1170. }
  1171. // tenantName & email validation check
  1172. findId.value.validCheck.inputErrorCheck = _every(
  1173. findId.value.validCheck.input,
  1174. (value) => value === true
  1175. );
  1176. //!useUtil.isNull(findId.value.tenantName) &&
  1177. if (!useUtil.isNull(findId.value.email) && !useUtil.isNull(findId.value.otpNum)) {
  1178. validAllCheck.inputCheck = findId.value.validCheck.inputErrorCheck;
  1179. validAllCheck.otpCheck = findId.value.validCheck.otp.otpNum;
  1180. }
  1181. findId.value.validCheck.findIdValidCheck = _every(
  1182. validAllCheck,
  1183. (value) => value === true
  1184. );
  1185. } else if (_includes(input, "resetPw_")) {
  1186. let validAllCheck = {
  1187. inputCheck: false,
  1188. otpCheck: false,
  1189. };
  1190. if (input === "resetPw_userId") {
  1191. if (useUtil.isNull(resetPw.value.userId)) {
  1192. resetPw.value.validCheck.input.userId = false;
  1193. resetPw.value.validCheck.inputValidTxt = i18n.t(
  1194. "login.resetPasswd.valid.isNullUserId"
  1195. );
  1196. } else {
  1197. resetPw.value.validCheck.input.userId = true;
  1198. if (!useUtil.isNull(resetPw.value.email)) {
  1199. fnValidCheck("resetPw_email");
  1200. }
  1201. }
  1202. } else if (input === "resetPw_email") {
  1203. if (useUtil.isNull(resetPw.value.email)) {
  1204. resetPw.value.validCheck.input.email = false;
  1205. resetPw.value.validCheck.inputValidTxt = i18n.t(
  1206. "login.resetPasswd.valid.isNullEmail"
  1207. );
  1208. } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(resetPw.value.email)) {
  1209. resetPw.value.validCheck.input.email = false;
  1210. resetPw.value.validCheck.inputValidTxt = i18n.t(
  1211. "login.resetPasswd.valid.isTypeEmail"
  1212. );
  1213. } else {
  1214. resetPw.value.validCheck.input.email = true;
  1215. }
  1216. } else if (input === "resetPw_otpNum") {
  1217. resetPw.value.otpNum = useValid.p5gNumCheck(resetPw.value.otpNum, "otp");
  1218. if (useUtil.isNull(resetPw.value.otpNum) || resetPw.value.otpNum.length <= 5) {
  1219. resetPw.value.validCheck.otp.otpNum = false;
  1220. resetPw.value.validCheck.otpValidTxt = i18n.t(
  1221. "login.resetPasswd.valid.isNullOtp"
  1222. );
  1223. } else {
  1224. resetPw.value.validCheck.otp.otpNum = true;
  1225. }
  1226. }
  1227. // tenantName & email validation check
  1228. resetPw.value.validCheck.inputErrorCheck = _every(
  1229. resetPw.value.validCheck.input,
  1230. (value) => value === true
  1231. );
  1232. if (
  1233. !useUtil.isNull(resetPw.value.userId) &&
  1234. !useUtil.isNull(resetPw.value.email) &&
  1235. !useUtil.isNull(resetPw.value.otpNum)
  1236. ) {
  1237. validAllCheck.inputCheck = resetPw.value.validCheck.inputErrorCheck;
  1238. validAllCheck.otpCheck = resetPw.value.validCheck.otp.otpNum;
  1239. }
  1240. resetPw.value.validCheck.resetPwValidCheck = _every(
  1241. validAllCheck,
  1242. (value) => value === true
  1243. );
  1244. } else {
  1245. if (input === "initPw_passwd") {
  1246. let digits1 = useAuthStore().getAuth.phoneNumber.replace(/\D/g, "");
  1247. let digits2 = initPw.value.passwd.replace(/\D/g, "");
  1248. let lastEightDigits1 = digits1.slice(-8);
  1249. let lastEightDigits2 = digits2.slice(-8);
  1250. if (useUtil.isNull(initPw.value.passwd)) {
  1251. initPw.value.validCheck.passwd = false;
  1252. initPw.value.errorTxt = i18n.t("login.valid.isNullNewPassword");
  1253. } else if (_includes(initPw.value.passwd, useAuthStore().getAuth.accountId)) {
  1254. // 아이디는 비밀번호로 사용할 수 없습니다.
  1255. initPw.value.validCheck.passwd = false;
  1256. initPw.value.errorTxt = i18n.t(
  1257. "common.header.myInfoUpdateModal.valid.includeId"
  1258. );
  1259. } else if (lastEightDigits1 === lastEightDigits2) {
  1260. // 연락처와 유사한 비밀번호는 사용할 수 없습니다.
  1261. initPw.value.validCheck.passwd = false;
  1262. initPw.value.errorTxt = i18n.t(
  1263. "common.header.myInfoUpdateModal.valid.includePhone"
  1264. );
  1265. } else if (/(.)\1{2,}/.test(initPw.value.passwd)) {
  1266. // 3자리 이상 연속 숫자, 문자는 사용 불가합니다.
  1267. initPw.value.validCheck.passwd = false;
  1268. initPw.value.errorTxt = i18n.t(
  1269. "common.header.myInfoUpdateModal.valid.continuousUse"
  1270. );
  1271. } else if (
  1272. !/^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{8,30}$/i.test(
  1273. initPw.value.passwd
  1274. )
  1275. ) {
  1276. // 비밀번호는 문자,숫자,특수문자 조합 8~30자리로입력
  1277. initPw.value.validCheck.passwd = false;
  1278. initPw.value.errorTxt = i18n.t(
  1279. "common.header.myInfoUpdateModal.valid.validPassword"
  1280. );
  1281. } else {
  1282. initPw.value.validCheck.passwd = true;
  1283. if (!useUtil.isNull(initPw.value.passwd2)) {
  1284. fnValidCheck("initPw_passwd2");
  1285. }
  1286. }
  1287. } else {
  1288. if (initPw.value.passwd != initPw.value.passwd2) {
  1289. // 신규비밀번호가 일치 하지 않습니다.
  1290. initPw.value.validCheck.passwd2 = false;
  1291. initPw.value.errorTxt = i18n.t(
  1292. "common.header.myInfoUpdateModal.valid.missmatchPassword"
  1293. );
  1294. } else {
  1295. initPw.value.validCheck.passwd2 = true;
  1296. }
  1297. }
  1298. if (!useUtil.isNull(initPw.value.passwd) && !useUtil.isNull(initPw.value.passwd2)) {
  1299. initPw.value.passwdCheck = _every(
  1300. initPw.value.validCheck,
  1301. (value) => value === true
  1302. );
  1303. }
  1304. }
  1305. }
  1306. </script>