index.vue 42 KB

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