434 lines
15 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div
  3. class="tw-bg-white md:tw-rounded-[24px] md:tw-mt-[30px] md:tw-pt-[60px] md:tw-pb-[150px] md:tw-px-[30px]"
  4. >
  5. <div v-if="getPath == null">
  6. <p class="tw-text-[26px] tw-font-bold tw-mb-[20px] md:tw-text-[18px]">
  7. {{ $t("Forgot Password") }}
  8. </p>
  9. <p class="tw-body-3 tw-text-black tw-mb-[24px]">
  10. {{
  11. $t(
  12. "Dont worry! It happens. Please enter the address associated with your account."
  13. )
  14. }}
  15. </p>
  16. <div v-if="wrongMessageActive" class="warning--text text-size-14 ps-1 mb-3">
  17. {{ $t('The Email entered is incorrect') }}
  18. </div>
  19. <v-form v-model="resendValid">
  20. <v-text-field
  21. v-model="Email"
  22. background-color="neutrals darken-1"
  23. :label="this.$t('Email')"
  24. placeholder=""
  25. filled
  26. rounded
  27. dense
  28. single-line
  29. :rules="[rules.email, rules.require]"
  30. ></v-text-field>
  31. </v-form>
  32. <div class="md:tw-flex md:tw-justify-center md:tw-items-center">
  33. <button
  34. @click="sendForgotMail"
  35. :class="[
  36. 'tw-block tw-w-full tw-py-[10px] tw-rounded-[16px] tw-border tw-border-solid tw-body-3 tw-font-normal tw-transition-all tw-duration-200 tw-ease-in-out',
  37. resendValid
  38. ? 'tw-text-white tw-bg-primary-default tw-border-primary-default'
  39. : 'tw-text-base-disable tw-bg-neutral-100 tw-border-neutral-100',
  40. ]"
  41. >
  42. {{ $t("Reset Password")
  43. }}<span v-if="disableBtn">({{ this.countdown }})</span>
  44. </button>
  45. </div>
  46. </div>
  47. <div v-if="getPath != null && resetSuccess == false">
  48. <p class="title">{{ $t("Reset Password") }}</p>
  49. <v-form v-model="resetValid">
  50. <v-text-field
  51. v-model="userData.Password"
  52. background-color="neutrals darken-1"
  53. :label="this.$t('Password') + '*'"
  54. :type="showPass ? 'text' : 'password'"
  55. placeholder=""
  56. filled
  57. rounded
  58. dense
  59. single-line
  60. persistent-hint
  61. :rules="[rules.checkPassword, rules.require]"
  62. :hint="
  63. this.$t(
  64. 'Passwords must be 8-20 characters with at least 1 number, 1 lower case letter and 1 upper case letter'
  65. )
  66. "
  67. :append-icon="showPass ? 'mdi-eye' : 'mdi-eye-off'"
  68. @click:append="showPass = !showPass"
  69. ></v-text-field>
  70. <v-text-field
  71. v-model="userConfirmPass"
  72. background-color="neutrals darken-1"
  73. :label="this.$t('Confirm Password') + '*'"
  74. :type="showConfirmPass ? 'text' : 'password'"
  75. placeholder=""
  76. filled
  77. rounded
  78. dense
  79. single-line
  80. :rules="[rules.checkPassword, rules.require, rules.confirmPass]"
  81. :append-icon="showConfirmPass ? 'mdi-eye' : 'mdi-eye-off'"
  82. @click:append="showConfirmPass = !showConfirmPass"
  83. ></v-text-field>
  84. </v-form>
  85. <div class="md:tw-flex md:tw-justify-center md:tw-items-center">
  86. <button
  87. @click="resetUserPass"
  88. :class="[
  89. 'tw-block tw-w-full tw-py-[10px] tw-rounded-[16px] tw-border tw-border-solid tw-body-3 tw-font-normal tw-transition-all tw-duration-200 tw-ease-in-out tw-text-white tw-bg-primary-default tw-border-primary-default']"
  90. >
  91. {{ $t("Reset Password") }}
  92. </button>
  93. </div>
  94. </div>
  95. <div v-if="resetSuccess">
  96. <p class="title">{{ $t("Password Reset") }}</p>
  97. <p class="neutrals--text text--darken-5 text-size-14">
  98. {{ $t("Congrats! Your password has been successfully reset") }}
  99. </p>
  100. <nuxt-link :to="localePath('/')">
  101. <v-btn
  102. @click="redirectHome"
  103. width="100%"
  104. color="primary"
  105. class="border-radius-16 mt-4"
  106. >
  107. <span class="text-capitalize">{{ $t("Explore with ShowEasy") }}</span>
  108. </v-btn>
  109. </nuxt-link>
  110. <v-spacer class="d-flex justify-center mt-5">
  111. <span
  112. class="text-size-12 primary--text"
  113. v-html="$t('Go to ShowEasy in sec', { second: this.countdown })"
  114. ></span>
  115. </v-spacer>
  116. </div>
  117. <v-dialog v-model="dialog" :width="$vuetify.breakpoint.smAndUp ? 423 : 294"
  118. @click:outside="colseDialog()">
  119. <v-card class="tw-p-[30px]" :height="$vuetify.breakpoint.smAndUp ? 289 : 290">
  120. <v-spacer class="d-flex align-center tw-justify-between tw-mb-[30px]">
  121. <div class="tw-text-[20px] tw-font-bold tw-text-black">
  122. {{ $t("Verify your email") }}
  123. </div>
  124. <v-btn @click="colseDialog()" icon>
  125. <v-icon> mdi-close </v-icon>
  126. </v-btn>
  127. </v-spacer>
  128. <v-spacer class="tw-mb-[40px]">
  129. <div class="tw-text-[16px] tw-text-neutrals-800">
  130. {{ $t("Oops! Seems like you haven't verified your email,please click the button below to resend a verification email.")}}
  131. </div>
  132. </v-spacer>
  133. <button @click="resendVerifyEmail()" class="tw-bg-primary-1 hover:tw-bg-primary-light tw-text-white tw-text-[18px] tw-rounded-[16px] tw-px-[77px] tw-py-[13px]">
  134. {{ $t("Resend verification email") }}
  135. </button>
  136. <!-- <v-btn @click="resendVerifyEmail" class="primary tw-text-[18px] tw-w-auto" rounded
  137. :disabled="countdown > 0">
  138. <span v-if="countdown > 0">
  139. {{ `(${this.countdown})` }}
  140. </span>
  141. </v-btn> -->
  142. </v-card>
  143. </v-dialog>
  144. <v-dialog v-model="deleteDialog" :width="$vuetify.breakpoint.smAndUp ? 423 : 294"
  145. @click:outside="colseDialog()">
  146. <v-card class="tw-p-[30px]" :height="$vuetify.breakpoint.smAndUp ? 289 : 290">
  147. <v-spacer class="d-flex tw-justify-between align-center tw-mb-[30px]">
  148. <div class="tw-text-[20px] tw-text-black tw-font-bold">
  149. {{ $t("Reactivate your account") }}
  150. </div>
  151. <v-btn @click="colseDialog()" icon>
  152. <v-icon> mdi-close </v-icon>
  153. </v-btn>
  154. </v-spacer>
  155. <v-spacer class="tw-mb-[40px]">
  156. <div class="tw-text-[16px] tw-text-neutrals-800 tw-font-bold">
  157. {{ $t("Welcome back!")}}
  158. </div>
  159. <div class="tw-text-[16px] tw-text-neutrals-800">
  160. {{ $t("Looks like your account has been deactivated.")}}
  161. <br />
  162. {{ $t("Would you like to reactivate this account?")}}
  163. </div>
  164. </v-spacer>
  165. <button @click="ReactivateAccount()" class="tw-bg-primary-1 tw-text-white hover:tw-bg-primary-light tw-text-[18px] tw-rounded-[16px] tw-px-[86px] tw-py-[13px]">
  166. {{ $t("Reactivate my account") }}
  167. </button>
  168. <!-- <v-btn class="primary tw-w-auto" rounded
  169. :disabled="countdown > 0">
  170. <span v-if="countdown > 0">
  171. {{ `(${this.countdown})` }}
  172. </span>
  173. </v-btn> -->
  174. </v-card>
  175. </v-dialog>
  176. <v-dialog v-model="chackMailDialog" :width="$vuetify.breakpoint.smAndUp ? 463 : 294"
  177. @click:outside="colseDialog()">
  178. <v-card class="tw-p-[30px]" :height="$vuetify.breakpoint.smAndUp ? 289 : 290">
  179. <v-spacer class="d-flex tw-justify-between align-center tw-mb-[30px]">
  180. <div class="tw-text-[20px] tw-text-black tw-font-bold">
  181. {{ $t("Check your email") }}
  182. </div>
  183. <v-btn @click="colseDialog()" icon>
  184. <v-icon> mdi-close </v-icon>
  185. </v-btn>
  186. </v-spacer>
  187. <v-spacer class="tw-mb-[40px]">
  188. <div class="tw-text-[16px] tw-text-neutrals-800 tw-font-bold">
  189. {{ $t("We've sent a password reset link to")}}
  190. </div>
  191. <div class="tw-text-[16px] tw-text-primary-1">
  192. {{ Email }}
  193. </div>
  194. <div class="tw-text-[16px] tw-text-neutrals-800 tw-font-bold">
  195. {{ $t("Please tap the link inside that email to continue.")}}
  196. </div>
  197. </v-spacer>
  198. <button @click="colseDialog()" class="tw-bg-primary-1 tw-text-white hover:tw-bg-primary-light tw-text-[18px] tw-rounded-[16px] tw-px-[169px] tw-py-[13px]">
  199. {{ $t("OK") }}
  200. </button>
  201. <!-- <v-btn class="primary tw-w-auto" rounded
  202. :disabled="countdown > 0">
  203. <span v-if="countdown > 0">
  204. {{ `(${this.countdown})` }}
  205. </span>
  206. </v-btn> -->
  207. </v-card>
  208. </v-dialog>
  209. </div>
  210. </template>
  211. <script>
  212. export default {
  213. name: "Forgot",
  214. layout: "login",
  215. auth: false,
  216. data() {
  217. return {
  218. showPass: false,
  219. showConfirmPass: false,
  220. resendValid: false,
  221. resetValid: false,
  222. disableBtn: false,
  223. resetSuccess: false,
  224. countdown: 5,
  225. Email: "",
  226. userConfirmPass: "",
  227. userData: {
  228. //user_id: "",
  229. //auth_code: "",
  230. Password: "",
  231. },
  232. result: "",
  233. getPath: null,
  234. rules: {
  235. require: (value) => !!value || this.$t("Required."),
  236. email: (v) =>
  237. /^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/.test(
  238. v
  239. ) || this.$t("Invalid email"),
  240. checkPassword: (v) =>
  241. (/(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])/.test(v) &&
  242. v.length >= 8 &&
  243. v.length <= 20) ||
  244. this.$t(
  245. "Passwords must be 8-20 characters with at least 1 number, 1 lower case letter and 1 upper case letter"
  246. ),
  247. confirmPass: (v) =>
  248. v === this.userData.Password ||
  249. this.$t("Your password and confirmation password do not match"),
  250. },
  251. dialog: false,
  252. deleteDialog: false,
  253. wrongMessageActive: false,
  254. chackMailDialog: false,
  255. };
  256. },
  257. created(){
  258. this.$auth.$storage.removeUniversal('userPassword');
  259. this.$auth.$storage.removeUniversal('userAccount');
  260. this.getPAth();
  261. },
  262. methods: {
  263. colseDialog(){
  264. this.dialog = false;
  265. if(this.dialog == false){
  266. this.resendValid = false;
  267. }
  268. this.deleteDialog = false;
  269. if(this.deleteDialog == false){
  270. this.resendValid = false;
  271. }
  272. this.chackMailDialog = false;
  273. if(this.chackMailDialog == false){
  274. this.resendValid = false;
  275. }
  276. },
  277. getPAth(){
  278. let vm = this;
  279. if (this.$route.query.Email) {
  280. vm.getPath = vm.$route.query.Email;
  281. }else{
  282. vm.getPath = null;
  283. }
  284. },
  285. sendForgotMail() {
  286. this.countdown = 60;
  287. this.resendValid = false;
  288. this.$axios
  289. .post(`/trending/api/Signup/SendForgotMail?Email=${this.Email}`)
  290. .then((response) => {
  291. //console.log(JSON.stringify(response));
  292. if(response.data.STATUSCODE == "404"){
  293. this.resendValid = false;
  294. if(response.data.MSG == "0"){
  295. this.dialog = true;
  296. }else if(response.data.MSG == "2"){
  297. this.deleteDialog = true;
  298. }else{
  299. this.wrongMessageActive = true;
  300. }
  301. }
  302. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  303. let data = response.data.DATA.rel
  304. if(data){
  305. this.result = data;
  306. this.disableBtn = false;
  307. this.resendValid = false;
  308. this.chackMailDialog = true;
  309. this.disableBtn = !this.disableBtn;
  310. this.timeout = setInterval(() => {
  311. if (this.countdown > 0) {
  312. this.countdown--;
  313. }
  314. if (this.countdown == 0) {
  315. this.resendValid = true;
  316. this.disableBtn = true;
  317. this.countdown = 60;
  318. clearInterval(this.timeout);
  319. }
  320. }, 1000);
  321. }
  322. }
  323. })
  324. .catch((error) => {
  325. console.log(error);
  326. });
  327. },
  328. resetUserPass() {
  329. if (
  330. this.userData.Password === this.userConfirmPass &&
  331. this.resetValid
  332. ) {
  333. //this.userData.user_id = this.$route.query.user_uuid;
  334. //this.userData.auth_code = this.$route.query.auth_code;
  335. this.$axios
  336. .post(`/trending/api/Signup/ResetPassword?Email=${this.getPath}&Password=${this.userData.Password}`)
  337. .then((response) => {
  338. //console.log(JSON.stringify(response));
  339. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  340. let data = response.data.DATA.rel
  341. if(data){
  342. this.resetSuccess = !this.resetSuccess;
  343. this.countdown = 3;
  344. this.timer = setInterval(() => {
  345. if (this.countdown > 0) {
  346. this.countdown--;
  347. } else {
  348. clearInterval(this.timer);
  349. this.$router.push(this.localePath("/"));
  350. }
  351. }, 1000);
  352. }
  353. }
  354. })
  355. .catch((error) => {
  356. console.log(error);
  357. });
  358. }
  359. },
  360. resendVerifyEmail() {
  361. this.countdown = 60;
  362. this.$axios
  363. .post(
  364. `/trending/api/Signup/ReSendVerifyMail?Email=${this.Email}`
  365. )
  366. .then((response) => {
  367. //console.log(JSON.stringify(response))
  368. if(response && response.data){
  369. this.dialog = false;
  370. this.resendValid = true;
  371. clearInterval(this.timer);
  372. this.timer = setInterval(() => {
  373. if (this.countdown > 0) {
  374. this.countdown--;
  375. }
  376. if (this.countdown === 0) {
  377. clearInterval(this.timer);
  378. }
  379. }, 1000);
  380. }
  381. })
  382. .catch((error) => {
  383. console.log(error);
  384. });
  385. },
  386. ReactivateAccount(){
  387. this.$axios
  388. .post(
  389. `/trending/api/Members/ReactivateAccount?Email=${this.Email}`
  390. )
  391. .then((response) => {
  392. //console.log(JSON.stringify(response))
  393. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  394. let data = response.data.DATA.rel
  395. if(data){
  396. this.deleteDialog = false;
  397. window.location.href = '/';
  398. }
  399. }
  400. })
  401. .catch((error) => {
  402. console.log(error);
  403. });
  404. },
  405. },
  406. beforeUnmount() {
  407. clearInterval(this.timeout);
  408. clearInterval(this.timer);
  409. },
  410. };
  411. </script>
  412. <style scoped>
  413. .title {
  414. font-weight: 700;
  415. font-size: 26px;
  416. line-height: 34px;
  417. letter-spacing: 0.02em;
  418. color: #232323;
  419. }
  420. </style>