From 69c6c883c2f72b3fe0c827bf351dca676b100749 Mon Sep 17 00:00:00 2001 From: MakerLab-Dev <47223013+MakerLab-Dev@users.noreply.github.com> Date: Thu, 3 Dec 2020 19:04:50 +0100 Subject: [PATCH] Password reset update --- .../V1/Auth/IsRegisteredController.php | 25 ------------- .../assets/js/store/modules/auth/actions.js | 13 ------- .../assets/js/views/auth/ForgotPassword.vue | 36 +++++++------------ routes/api.php | 8 +---- 4 files changed, 14 insertions(+), 68 deletions(-) delete mode 100644 app/Http/Controllers/V1/Auth/IsRegisteredController.php diff --git a/app/Http/Controllers/V1/Auth/IsRegisteredController.php b/app/Http/Controllers/V1/Auth/IsRegisteredController.php deleted file mode 100644 index 69682e7c..00000000 --- a/app/Http/Controllers/V1/Auth/IsRegisteredController.php +++ /dev/null @@ -1,25 +0,0 @@ -email)->first()) { - return 'true'; - } else { - return 'false'; - } - } -} diff --git a/resources/assets/js/store/modules/auth/actions.js b/resources/assets/js/store/modules/auth/actions.js index be471ff9..1851377f 100644 --- a/resources/assets/js/store/modules/auth/actions.js +++ b/resources/assets/js/store/modules/auth/actions.js @@ -48,16 +48,3 @@ export const logout = ({ state, commit }) => { }) }) } - -export const checkMail = ({ commit }, data) => { - return new Promise((resolve, reject) => { - window.axios - .post('/api/v1/is-registered', data) - .then((response) => { - resolve(response) - }) - .catch((err) => { - reject(err) - }) - }) -} diff --git a/resources/assets/js/views/auth/ForgotPassword.vue b/resources/assets/js/views/auth/ForgotPassword.vue index 7341a86f..b0f86551 100644 --- a/resources/assets/js/views/auth/ForgotPassword.vue +++ b/resources/assets/js/views/auth/ForgotPassword.vue @@ -20,19 +20,24 @@ - {{ $t('validation.send_reset_link') }} - - - {{ $t('validation.not_yet') }} +
+ {{ $t('validation.send_reset_link') }} +
+
+ {{ $t('validation.not_yet') }} +
- + {{ $t('general.back_to_login') }}
@@ -52,7 +57,6 @@ export default { }, isSent: false, isLoading: false, - isRegisteredUser: false, } }, validations: { @@ -64,14 +68,9 @@ export default { }, }, methods: { - ...mapActions('auth', ['checkMail']), + ...mapActions('auth'), async validateBeforeSubmit(e) { this.$v.formData.$touch() - let { data } = await this.checkMail() - if (data === false) { - toastr['error'](this.$t('validation.email_does_not_exist')) - return - } if (!this.$v.formData.$invalid) { try { this.isLoading = true @@ -87,19 +86,10 @@ export default { this.isSent = true this.isLoading = false } catch (err) { - if (err.response && err.response.status === 403) { - toastr['error'](err.response.data, 'Error') - } + this.isLoading = false } } }, - // async checkMail() { - // let response = await window.axios.post( - // '/api/v1/is-registered', - // this.formData - // ) - // return response.data - // }, }, } diff --git a/routes/api.php b/routes/api.php index f8848235..ca34f6a5 100644 --- a/routes/api.php +++ b/routes/api.php @@ -96,12 +96,6 @@ Route::prefix('/v1')->group(function () { Route::get('/app/version', AppVersionController::class); - // Email is registered - // ---------------------------------- - - Route::get('/is/registered', IsRegisteredController::class); - - // Authentication & Password Reset //---------------------------------- @@ -112,7 +106,7 @@ Route::prefix('/v1')->group(function () { Route::post('logout', [AuthController::class, 'logout'])->middleware('auth:sanctum'); // Send reset password mail - Route::post('password/email', [ForgotPasswordController::class, 'sendResetLinkEmail']); + Route::post('password/email', [ForgotPasswordController::class, 'sendResetLinkEmail'])->middleware("throttle:10,2");; // handle reset password form process Route::post('reset/password', [ResetPasswordController::class, 'reset']);