You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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