#1096 Register - Instant GSM phone control

This commit is contained in:
Diatrex 2020-03-18 16:36:21 +03:00
parent 662e17b330
commit 6280d77fb6
6 changed files with 96 additions and 12 deletions

View File

@ -11,4 +11,19 @@
.personal-advantages img {
max-height: 60px;
max-width: 60px;
}
.approved-phone {
background-color: #ebf2e5 !important;
border-color: #4a7c20 !important;
}
.rejected-phone {
background-color: #f8e6e9 !important;
border-color: #ba7b84 !important;
}
.phone-validation-error {
color: #c75050;
font-size: 14px;
}

View File

@ -1 +1,48 @@
phoneMask("input[name='phone'],input[name='land_phone']");
// Phone register validation
//setup before functions
let typingTimer;
let doneTypingInterval = 650;
let phoneInput = $(".validate-phone input[name='phone']");
//on keyup, start the countdown
phoneInput.on('keyup', function () {
clearTimeout(typingTimer);
typingTimer = setTimeout(function () {
doneTyping(phoneInput.val())
}, doneTypingInterval)
});
//on keydown, clear the countdown
phoneInput.on('keydown', function () {
clearTimeout(typingTimer);
});
function doneTyping(phoneNum) {
if (!phoneNum.includes('_') && phoneNum !== "") {
let countryCode = $(".iti__selected-flag").attr('title').split("+");
countryCode = '+' + countryCode[countryCode.length - 1];
$.ajax({
type: 'GET',
data: {'phoneNumber': countryCode + phoneNum.substr(1)},
url: 'ajax/phone-validation',
success: function (response) {
if (response.userExists) {
phoneInput.addClass('rejected-phone');
phoneInput.removeClass('approved-phone');
$('.phone-validation-error').removeClass('d-none')
} else {
phoneInput.addClass('approved-phone');
phoneInput.removeClass('rejected-phone');
$('.phone-validation-error').addClass('d-none')
}
},
});
} else {
phoneInput.removeClass('approved-phone');
phoneInput.removeClass('rejected-phone');
$('.phone-validation-error').addClass('d-none')
}
}

View File

@ -31,6 +31,9 @@ return [
'personal_registration_list_3' => 'Send messages to the ad owners on the site.',
'register_information_note' => 'The information on this page is taken for ' . env('APPLICATION_DOMAIN') . ' membership. You can find detailed information about the protection of personal data here.',
// Register page
'phone_validation_error' => 'This email address is in use by another member.',
// Forgot Password
'create_new_password' => 'Create New Password',
];

View File

@ -47,6 +47,25 @@
'class' :'hidden',
}).input|raw }}
{% endif %}
<div class="col-12">
<div class="form-group email-field phone-field_type register-phone mb-2">
<label class="control-label">
{{ trans('visiosoft.theme.base::field.phone_number') }}
<span class="required">*</span>
</label>
<div class="input-wrapper validate-phone">
{{ form.fields.phone.setValue(form.fields.phone.value).input|raw }}
</div>
</div>
</div>
<div class="col-12 mb-3">
<p class="phone-validation-error mb-0 d-none">
<i class="fa fa-times-circle"></i>
{{ trans('visiosoft.theme.base::field.phone_validation_error') }}
</p>
</div>
<div class="col-12">
<div class="form-group password-field password-field_type">
<label class="control-label">
@ -58,16 +77,4 @@
{{ form.fields.password.setPlaceholder(trans('visiosoft.theme.base::field.password')).input|raw }}
</div>
</div>
</div>
<div class="col-12">
<div class="form-group email-field phone-field_type register-phone">
<label class="control-label">
{{ trans('visiosoft.theme.base::field.phone_number') }}
<span class="required">*</span>
</label>
<div class="input-wrapper">
{{ form.fields.phone.setValue(form.fields.phone.value).input|raw }}
</div>
</div>
</div>

View File

@ -224,4 +224,15 @@ class UserAuthenticator
{
return response()->json(['status' => $type, 'message' => $message]);
}
public function phoneValidation(Request $request, UserRepositoryInterface $userRepository)
{
$phoneNum = str_replace(' ', '', $request->phoneNumber);
$userExists = $userRepository->findBy('gsm_phone', $phoneNum);
if ($userExists) {
return response()->json(['userExists' => true]);
} else {
return response()->json(['userExists' => false]);
}
}
}

View File

@ -111,6 +111,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
\Barryvdh\Cors\HandleCors::class,
]
],
'ajax/phone-validation' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@phoneValidation',
/* Login */
'login-in' => 'Visiosoft\ProfileModule\Http\Controller\UserAuthenticator@attempt',