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.

377 lines
13 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 @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]">
  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: 60,
  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 = false;
  264. console.log(this.disableBtn);
  265. this.countdown = 60;
  266. console.log(this.countdown);
  267. clearInterval(this.timeout);
  268. }
  269. }, 1000);
  270. }
  271. }
  272. })
  273. .catch((error) => {
  274. console.log(error);
  275. });
  276. },
  277. resetUserPass() {
  278. if (
  279. this.userData.Password === this.userConfirmPass &&
  280. this.resetValid
  281. ) {
  282. //this.userData.user_id = this.$route.query.user_uuid;
  283. //this.userData.auth_code = this.$route.query.auth_code;
  284. this.$axios
  285. .post(`/trending/api/Signup/ResetPassword?Email=${this.getPath}&Password=${this.userData.Password}`)
  286. .then((response) => {
  287. //console.log(JSON.stringify(response));
  288. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  289. let data = response.data.DATA.rel
  290. if(data){
  291. this.resetSuccess = !this.resetSuccess;
  292. this.countdown = 3;
  293. this.timer = setInterval(() => {
  294. if (this.countdown > 0) {
  295. this.countdown--;
  296. } else {
  297. clearInterval(this.timer);
  298. this.$router.push(this.localePath("/"));
  299. }
  300. }, 1000);
  301. }
  302. }
  303. })
  304. .catch((error) => {
  305. console.log(error);
  306. });
  307. }
  308. },
  309. resendVerifyEmail() {
  310. this.countdown = 60;
  311. this.$axios
  312. .post(
  313. `/trending/api/Signup/ReSendVerifyMail?Email=${this.Email}`
  314. )
  315. .then((response) => {
  316. //console.log(JSON.stringify(response))
  317. if(response && response.data){
  318. this.dialog = false;
  319. clearInterval(this.timer);
  320. this.timer = setInterval(() => {
  321. if (this.countdown > 0) {
  322. this.countdown--;
  323. }
  324. if (this.countdown === 0) {
  325. clearInterval(this.timer);
  326. }
  327. }, 1000);
  328. }
  329. })
  330. .catch((error) => {
  331. console.log(error);
  332. });
  333. },
  334. ReactivateAccount(){
  335. this.$axios
  336. .post(
  337. `/trending/api/Members/ReactivateAccount?Email=${this.Email}`
  338. )
  339. .then((response) => {
  340. //console.log(JSON.stringify(response))
  341. if(response && response.data && response.data.DATA && response.data.DATA.rel){
  342. let data = response.data.DATA.rel
  343. if(data){
  344. this.deleteDialog = false;
  345. }
  346. }
  347. })
  348. .catch((error) => {
  349. console.log(error);
  350. });
  351. }
  352. },
  353. beforeUnmount() {
  354. clearInterval(this.timeout);
  355. clearInterval(this.timer);
  356. },
  357. };
  358. </script>
  359. <style scoped>
  360. .title {
  361. font-weight: 700;
  362. font-size: 26px;
  363. line-height: 34px;
  364. letter-spacing: 0.02em;
  365. color: #232323;
  366. }
  367. </style>