fix customer email validation

This commit is contained in:
yogesh_gohil
2019-11-20 17:46:45 +05:30
parent 1e6372cbb1
commit 8b05909b74
3 changed files with 7 additions and 2 deletions

View File

@ -160,6 +160,7 @@ class CustomersController extends Controller
if ($verifyEmail) { if ($verifyEmail) {
if ($verifyEmail->id !== $customer->id) { if ($verifyEmail->id !== $customer->id) {
return response()->json([ return response()->json([
'success' => false,
'error' => 'Email already in use' 'error' => 'Email already in use'
]); ]);
} }

View File

@ -36,7 +36,6 @@ class CustomerRequest extends FormRequest
'name' => 'required', 'name' => 'required',
'addresses.*.address_street_1' => 'max:255', 'addresses.*.address_street_1' => 'max:255',
'addresses.*.address_street_2' => 'max:255', 'addresses.*.address_street_2' => 'max:255',
'email' => 'email|nullable|unique:users,email,'.$this->id
]; ];
break; break;
default: default:

View File

@ -586,11 +586,16 @@ export default {
this.isLoading = true this.isLoading = true
try { try {
let response = await this.updateCustomer(this.formData) let response = await this.updateCustomer(this.formData)
if (response.data) { if (response.data.success) {
window.toastr['success'](this.$t('customers.updated_message')) window.toastr['success'](this.$t('customers.updated_message'))
this.$router.push('/admin/customers') this.$router.push('/admin/customers')
this.isLoading = false this.isLoading = false
return true return true
} else {
this.isLoading = false
if (response.data.error) {
window.toastr['error'](this.$t('validation.email_already_taken'))
}
} }
} catch (err) { } catch (err) {
if (err.response.data.errors.email) { if (err.response.data.errors.email) {