index.vue 43 KB

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