mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Password reset update
This commit is contained in:
@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Crater\Http\Controllers\V1\Auth;
|
|
||||||
|
|
||||||
use Crater\Http\Controllers\Controller;
|
|
||||||
use Crater\Models\User;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
class IsRegisteredController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Handle the incoming request.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*/
|
|
||||||
public function __invoke(Request $request)
|
|
||||||
{
|
|
||||||
if (User::whereEmail($request->email)->first()) {
|
|
||||||
return 'true';
|
|
||||||
} else {
|
|
||||||
return 'false';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -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)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@ -20,19 +20,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<sw-button
|
<sw-button
|
||||||
v-if="!isSent"
|
:loading="isLoading"
|
||||||
:disabled="isLoading"
|
:disabled="isLoading"
|
||||||
type="submit"
|
type="submit"
|
||||||
variant="primary"
|
variant="primary"
|
||||||
>
|
>
|
||||||
{{ $t('validation.send_reset_link') }}
|
<div v-if="!isSent">
|
||||||
</sw-button>
|
{{ $t('validation.send_reset_link') }}
|
||||||
<sw-button v-else :disabled="isLoading" variant="primary" type="submit">
|
</div>
|
||||||
{{ $t('validation.not_yet') }}
|
<div v-else>
|
||||||
|
{{ $t('validation.not_yet') }}
|
||||||
|
</div>
|
||||||
</sw-button>
|
</sw-button>
|
||||||
|
|
||||||
<div class="mt-4 mb-4 text-sm">
|
<div class="mt-4 mb-4 text-sm">
|
||||||
<router-link to="/login">
|
<router-link
|
||||||
|
to="/login"
|
||||||
|
class="text-sm text-primary-400 hover:text-gray-700"
|
||||||
|
>
|
||||||
{{ $t('general.back_to_login') }}
|
{{ $t('general.back_to_login') }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
@ -52,7 +57,6 @@ export default {
|
|||||||
},
|
},
|
||||||
isSent: false,
|
isSent: false,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isRegisteredUser: false,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validations: {
|
validations: {
|
||||||
@ -64,14 +68,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('auth', ['checkMail']),
|
...mapActions('auth'),
|
||||||
async validateBeforeSubmit(e) {
|
async validateBeforeSubmit(e) {
|
||||||
this.$v.formData.$touch()
|
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) {
|
if (!this.$v.formData.$invalid) {
|
||||||
try {
|
try {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
@ -87,19 +86,10 @@ export default {
|
|||||||
this.isSent = true
|
this.isSent = true
|
||||||
this.isLoading = false
|
this.isLoading = false
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.response && err.response.status === 403) {
|
this.isLoading = false
|
||||||
toastr['error'](err.response.data, 'Error')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// async checkMail() {
|
|
||||||
// let response = await window.axios.post(
|
|
||||||
// '/api/v1/is-registered',
|
|
||||||
// this.formData
|
|
||||||
// )
|
|
||||||
// return response.data
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -96,12 +96,6 @@ Route::prefix('/v1')->group(function () {
|
|||||||
Route::get('/app/version', AppVersionController::class);
|
Route::get('/app/version', AppVersionController::class);
|
||||||
|
|
||||||
|
|
||||||
// Email is registered
|
|
||||||
// ----------------------------------
|
|
||||||
|
|
||||||
Route::get('/is/registered', IsRegisteredController::class);
|
|
||||||
|
|
||||||
|
|
||||||
// Authentication & Password Reset
|
// Authentication & Password Reset
|
||||||
//----------------------------------
|
//----------------------------------
|
||||||
|
|
||||||
@ -112,7 +106,7 @@ Route::prefix('/v1')->group(function () {
|
|||||||
Route::post('logout', [AuthController::class, 'logout'])->middleware('auth:sanctum');
|
Route::post('logout', [AuthController::class, 'logout'])->middleware('auth:sanctum');
|
||||||
|
|
||||||
// Send reset password mail
|
// 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
|
// handle reset password form process
|
||||||
Route::post('reset/password', [ResetPasswordController::class, 'reset']);
|
Route::post('reset/password', [ResetPasswordController::class, 'reset']);
|
||||||
|
|||||||
Reference in New Issue
Block a user