mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Merge branch 'master' of https://github.com/bytefury/crater
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';
|
||||
}
|
||||
}
|
||||
}
|
||||
4
resources/assets/js/bootstrap.js
vendored
4
resources/assets/js/bootstrap.js
vendored
@ -97,7 +97,7 @@ global.axios.interceptors.response.use(undefined, function (err) {
|
||||
}
|
||||
if (!err.response) {
|
||||
window.toastr['error'](
|
||||
'Network error: Please check your internet connection or wait until servers are back online'
|
||||
'Please check your internet connection or wait until servers are back online', 'Network Error'
|
||||
)
|
||||
} else {
|
||||
if (
|
||||
@ -121,7 +121,7 @@ global.axios.interceptors.response.use(undefined, function (err) {
|
||||
window.toastr['error'](
|
||||
err.response.data.message
|
||||
? err.response.data.message
|
||||
: 'Unknown error occurred'
|
||||
: err.response.data || 'Unknown error occurred', 'Error'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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>
|
||||
<sw-button
|
||||
v-if="!isSent"
|
||||
:loading="isLoading"
|
||||
:disabled="isLoading"
|
||||
type="submit"
|
||||
variant="primary"
|
||||
>
|
||||
{{ $t('validation.send_reset_link') }}
|
||||
</sw-button>
|
||||
<sw-button v-else :disabled="isLoading" variant="primary" type="submit">
|
||||
{{ $t('validation.not_yet') }}
|
||||
<div v-if="!isSent">
|
||||
{{ $t('validation.send_reset_link') }}
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ $t('validation.not_yet') }}
|
||||
</div>
|
||||
</sw-button>
|
||||
|
||||
<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') }}
|
||||
</router-link>
|
||||
</div>
|
||||
@ -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
|
||||
// },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user