index.vue 41 KB

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