mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
#722 Using cell phone
This commit is contained in:
parent
95099d377a
commit
7fb6730fd9
@ -20,4 +20,5 @@ return [
|
|||||||
'not_a_member_yet' => 'Not a Member Yet',
|
'not_a_member_yet' => 'Not a Member Yet',
|
||||||
'not_a_member_yet_message' => 'Sign up for our members to benefit from our special service',
|
'not_a_member_yet_message' => 'Sign up for our members to benefit from our special service',
|
||||||
'forgot_password' => 'I Forgot My Password',
|
'forgot_password' => 'I Forgot My Password',
|
||||||
|
'email_or_phone_number' => 'Email Address or Phone Number'
|
||||||
];
|
];
|
||||||
@ -20,4 +20,5 @@ return [
|
|||||||
'not_a_member_yet' => 'Henüz Üye Değil Misiniz',
|
'not_a_member_yet' => 'Henüz Üye Değil Misiniz',
|
||||||
'not_a_member_yet_message' => 'Üyelerimize özel hizmetlerimizden faydalanabilmek için üye olun',
|
'not_a_member_yet_message' => 'Üyelerimize özel hizmetlerimizden faydalanabilmek için üye olun',
|
||||||
'forgot_password' => 'Şifremi Unuttum',
|
'forgot_password' => 'Şifremi Unuttum',
|
||||||
|
'email_or_phone_number' => 'E-Posta Adresiniz veya Telefon Numaranız'
|
||||||
];
|
];
|
||||||
@ -5,7 +5,7 @@
|
|||||||
<div class="col-12 text-left p-3 m-0 row justify-content-center">
|
<div class="col-12 text-left p-3 m-0 row justify-content-center">
|
||||||
|
|
||||||
<div class="col-12 col-lg-5 m-3 login-section">
|
<div class="col-12 col-lg-5 m-3 login-section">
|
||||||
{% set form = form('login')
|
{% set form = form('signIn')
|
||||||
.redirect(app.request.get('redirect'))
|
.redirect(app.request.get('redirect'))
|
||||||
.get() %}
|
.get() %}
|
||||||
{{ form_open({
|
{{ form_open({
|
||||||
@ -18,7 +18,7 @@
|
|||||||
</h5>
|
</h5>
|
||||||
<div class="form-group email-field email-field_type">
|
<div class="form-group email-field email-field_type">
|
||||||
<label class="control-label">
|
<label class="control-label">
|
||||||
{{ trans('visiosoft.theme.base::field.email') }}
|
{{ trans('visiosoft.theme.base::field.email_or_phone_number') }}
|
||||||
<span class="required">*</span>
|
<span class="required">*</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="form-group email-field email-field_type">
|
<div class="form-group email-field email-field_type">
|
||||||
<label class="control-label">
|
<label class="control-label">
|
||||||
{{ trans('visiosoft.theme.base::field.email') }}
|
{{ trans('visiosoft.theme.base::field.email_or_phone_number') }}
|
||||||
<span class="required">*</span>
|
<span class="required">*</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|||||||
@ -22,4 +22,6 @@ return [
|
|||||||
'please_confirm_transaction' => 'Please Confirm Transaction',
|
'please_confirm_transaction' => 'Please Confirm Transaction',
|
||||||
'password_do_not_match' => 'Passwords do not match',
|
'password_do_not_match' => 'Passwords do not match',
|
||||||
'your_password_changed' => 'Your password was successfully updated',
|
'your_password_changed' => 'Your password was successfully updated',
|
||||||
|
'error_valid_email_or_phone' => 'Phone number or E-mail address format is not correct.',
|
||||||
|
'registered_phone' => 'This phone number has already been registered.',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"email" => "Eposta alanı zorunludur!",
|
"email" => "Eposta alanı zorunludur!",
|
||||||
"username" => "Kullanıcı Adı alanı zorunludur!",
|
"username" => "Kullanıcı Adı alanı zorunludur!",
|
||||||
"success_update" => "Profil Başarıyla Güncellendi!",
|
"success_update" => "Profil Başarıyla Güncellendi!",
|
||||||
"adress_success_update" => "Adres Başarıyla Güncellendi!",
|
"adress_success_update" => "Adres Başarıyla Güncellendi!",
|
||||||
"adress_success_create" => "Adres Başarıyla Oluşturuldu!",
|
"adress_success_create" => "Adres Başarıyla Oluşturuldu!",
|
||||||
"login_error" => "Giriş Bilgileri Hatalıdır.",
|
"login_error" => "Giriş Bilgileri Hatalıdır.",
|
||||||
"login_noMail_old_user" => "Girdiğiniz e-posta adresi bulunamadı.",
|
"login_noMail_old_user" => "Girdiğiniz e-posta adresi bulunamadı.",
|
||||||
"login_noMail_old_user2" => "Lütfen e-posta adresini kontrol edip tekrar deneyin.",
|
"login_noMail_old_user2" => "Lütfen e-posta adresini kontrol edip tekrar deneyin.",
|
||||||
@ -16,10 +16,12 @@ return [
|
|||||||
"notified_about_ads" => "Allow notifications about my ads",
|
"notified_about_ads" => "Allow notifications about my ads",
|
||||||
"receive_messages_email" => "I want to receive messages as email",
|
"receive_messages_email" => "I want to receive messages as email",
|
||||||
"no_packages_module" => "Paket Modülü Bulunamadı!",
|
"no_packages_module" => "Paket Modülü Bulunamadı!",
|
||||||
"required_add"=> "Lütfen gerekli tüm satırları doldurun.",
|
"required_add" => "Lütfen gerekli tüm satırları doldurun.",
|
||||||
"no_extend_package" => "İlan Yayınlama Süresi paketiniz bulunamadı.",
|
"no_extend_package" => "İlan Yayınlama Süresi paketiniz bulunamadı.",
|
||||||
"saved" => "Kayıt Edildi!",
|
"saved" => "Kayıt Edildi!",
|
||||||
'please_confirm_transaction' => 'Lütfen işlemi onaylayın',
|
'please_confirm_transaction' => 'Lütfen işlemi onaylayın',
|
||||||
'password_do_not_match' => 'Şifreler eşleşmiyor',
|
'password_do_not_match' => 'Şifreler eşleşmiyor',
|
||||||
'your_password_changed' => 'Şifreniz başarıyla güncellendi',
|
'your_password_changed' => 'Şifreniz başarıyla güncellendi',
|
||||||
|
'error_valid_email_or_phone' => 'E-Posta Adresi veya Telefon numarası formatı geçersiz.',
|
||||||
|
'registered_phone' => 'Bu telefon numarası ile daha önceden sisteme kayıt olunmuştur.',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -19,4 +19,6 @@ interface ProfileRepositoryInterface extends EntryRepositoryInterface
|
|||||||
public function findByUserID($id);
|
public function findByUserID($id);
|
||||||
|
|
||||||
public function CheckPhoneNumber($phoneNumber);
|
public function CheckPhoneNumber($phoneNumber);
|
||||||
|
|
||||||
|
public function findPhoneNumber($phone_number);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,5 +138,11 @@ class ProfileRepository extends EntryRepository implements ProfileRepositoryInte
|
|||||||
->first();
|
->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findPhoneNumber($phone_number)
|
||||||
|
{
|
||||||
|
return $this->model->where('gsm_phone', $phone_number)
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||||
use Visiosoft\ProfileModule\Profile\Register2\Command\AssociateActivationRoles;
|
use Visiosoft\ProfileModule\Profile\Register2\Command\AssociateActivationRoles;
|
||||||
use Visiosoft\ProfileModule\Profile\Register2\Command\SetOptions;
|
use Visiosoft\ProfileModule\Profile\Register2\Command\SetOptions;
|
||||||
use Anomaly\UsersModule\User\Validation\ValidatePassword;
|
|
||||||
use Anomaly\UsersModule\User\UserModel;
|
use Anomaly\UsersModule\User\UserModel;
|
||||||
|
use Visiosoft\ProfileModule\Profile\Validation\ValidateRegister;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RegisterFormBuilder
|
* Class RegisterFormBuilder
|
||||||
@ -47,7 +47,17 @@ class Register2FormBuilder extends FormBuilder
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
],
|
],
|
||||||
'email' => [
|
'email' => [
|
||||||
|
'type' => 'anomaly.field_type.text',
|
||||||
'instructions' => false,
|
'instructions' => false,
|
||||||
|
'rules' => [
|
||||||
|
'valid_register',
|
||||||
|
],
|
||||||
|
'validators' => [
|
||||||
|
'valid_register' => [
|
||||||
|
'message' => false,
|
||||||
|
'handler' => ValidateRegister::class,
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'password' => [
|
'password' => [
|
||||||
'instructions' => false,
|
'instructions' => false,
|
||||||
|
|||||||
@ -38,16 +38,24 @@ class Register2FormHandler
|
|||||||
UserActivator $activator
|
UserActivator $activator
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$builder->canSave()) {
|
if (!$builder->canSave()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$profile_parameters = array();
|
||||||
|
|
||||||
|
/* Create Profile in Register */
|
||||||
|
if (!filter_var($builder->getPostValue('email'), FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$profile_parameters['gsm_phone'] = $builder->getPostValue('email');
|
||||||
|
$builder->setFormValue('email', $builder->getPostValue('email') . "@" . setting_value('streams::domain'));
|
||||||
|
}
|
||||||
|
|
||||||
$builder->saveForm(); // Save the new user.
|
$builder->saveForm(); // Save the new user.
|
||||||
|
|
||||||
/* @var UserInterface $user */
|
/* @var UserInterface $user */
|
||||||
$user = $builder->getFormEntry();
|
$user = $builder->getFormEntry();
|
||||||
/* Create Profile in Register */
|
$profile_parameters['user_no_id'] = $user->getId();
|
||||||
ProfileModel::query()->create(['user_no_id' => $user->getId()]);
|
ProfileModel::query()->create($profile_parameters);
|
||||||
|
|
||||||
$activator->start($user);
|
$activator->start($user);
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,50 @@
|
|||||||
|
<?php namespace Visiosoft\ProfileModule\Profile\SignIn;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||||
|
use Anomaly\UsersModule\User\Contract\UserInterface;
|
||||||
|
use Anomaly\UsersModule\User\UserSecurity;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
|
||||||
|
class SignInFormBuilder extends FormBuilder
|
||||||
|
{
|
||||||
|
protected $model = false;
|
||||||
|
|
||||||
|
protected $user = null;
|
||||||
|
|
||||||
|
protected $actions = [
|
||||||
|
'blue' => [
|
||||||
|
'text' => 'anomaly.module.users::button.login',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $options = [
|
||||||
|
'redirect' => '/',
|
||||||
|
'breadcrumb' => false,
|
||||||
|
'success_message' => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
public function onPost(UserSecurity $security)
|
||||||
|
{
|
||||||
|
$response = $security->attempt();
|
||||||
|
|
||||||
|
if ($response instanceof Response) {
|
||||||
|
|
||||||
|
$this->setFormResponse($response);
|
||||||
|
|
||||||
|
$this->setSave(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUser()
|
||||||
|
{
|
||||||
|
return $this->user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUser(UserInterface $user)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
<?php namespace Visiosoft\ProfileModule\Profile\SignIn;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Config\Repository;
|
||||||
|
|
||||||
|
class SignInFormFields
|
||||||
|
{
|
||||||
|
public function handle(SignInFormBuilder $builder, Repository $config)
|
||||||
|
{
|
||||||
|
$method = $config->get('anomaly.module.users::config.login');
|
||||||
|
|
||||||
|
if ($method == 'username') {
|
||||||
|
$login = [
|
||||||
|
'username' => [
|
||||||
|
'label' => 'anomaly.module.users::field.username.name',
|
||||||
|
'type' => 'anomaly.field_type.text',
|
||||||
|
'required' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$login = [
|
||||||
|
'email' => [
|
||||||
|
'label' => 'anomaly.module.users::field.email.name',
|
||||||
|
'type' => 'anomaly.field_type.text',
|
||||||
|
'required' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->setFields(
|
||||||
|
array_merge(
|
||||||
|
$login,
|
||||||
|
[
|
||||||
|
'password' => [
|
||||||
|
'label' => 'anomaly.module.users::field.password.name',
|
||||||
|
'type' => 'anomaly.field_type.text',
|
||||||
|
'required' => true,
|
||||||
|
'config' => [
|
||||||
|
'type' => 'password',
|
||||||
|
],
|
||||||
|
'rules' => [
|
||||||
|
'valid_credentials',
|
||||||
|
],
|
||||||
|
'validators' => [
|
||||||
|
'valid_credentials' => [
|
||||||
|
'handler' => 'Visiosoft\ProfileModule\Profile\Validation\ValidateCredentials@handle',
|
||||||
|
'message' => 'anomaly.module.users::message.invalid_login',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'remember_me' => [
|
||||||
|
'label' => false,
|
||||||
|
'type' => 'anomaly.field_type.boolean',
|
||||||
|
'config' => [
|
||||||
|
'mode' => 'checkbox',
|
||||||
|
'label' => 'anomaly.module.users::field.remember_me.name',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
<?php namespace Visiosoft\ProfileModule\Profile\SignIn;
|
||||||
|
|
||||||
|
use Anomaly\UsersModule\User\UserAuthenticator;
|
||||||
|
use Anomaly\UsersModule\User\UserSecurity;
|
||||||
|
use Illuminate\Routing\Redirector;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
|
||||||
|
class SignInFormHandler
|
||||||
|
{
|
||||||
|
public function handle(
|
||||||
|
SignInFormBuilder $builder,
|
||||||
|
UserAuthenticator $authenticator,
|
||||||
|
UserSecurity $security,
|
||||||
|
Redirector $redirect
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!$user = $builder->getUser()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $security->check($user);
|
||||||
|
|
||||||
|
if ($response instanceof Response) {
|
||||||
|
|
||||||
|
$authenticator->logout($user);
|
||||||
|
|
||||||
|
$builder->setFormResponse($response);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$authenticator->login($user, $builder->getFormValue('remember_me'));
|
||||||
|
|
||||||
|
$builder->setFormResponse($redirect->intended($builder->getFormOption('redirect', '/')));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
<?php namespace Visiosoft\ProfileModule\Profile\Validation;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Addon\Extension\ExtensionCollection;
|
||||||
|
use Anomaly\UsersModule\User\Authenticator\Contract\AuthenticatorExtensionInterface;
|
||||||
|
use Anomaly\UsersModule\User\Contract\UserInterface;
|
||||||
|
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||||
|
use Visiosoft\ProfileModule\Profile\SignIn\SignInFormBuilder;
|
||||||
|
|
||||||
|
|
||||||
|
class ValidateCredentials
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
ExtensionCollection $extensions,
|
||||||
|
UserRepositoryInterface $userRepository,
|
||||||
|
ProfileRepositoryInterface $profileRepository
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->extensions = $extensions;
|
||||||
|
$this->repository = $userRepository;
|
||||||
|
$this->profile = $profileRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function authenticate(array $credentials)
|
||||||
|
{
|
||||||
|
$authenticators = $this->extensions
|
||||||
|
->search('anomaly.module.users::authenticator.*')
|
||||||
|
->enabled();
|
||||||
|
|
||||||
|
/* @var AuthenticatorExtensionInterface $authenticator */
|
||||||
|
foreach ($authenticators as $authenticator) {
|
||||||
|
if ($authenticator->slug == "default_authenticator") {
|
||||||
|
if (!isset($credentials['password']) && !isset($credentials['email'])) {
|
||||||
|
$response = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Is email or phone number
|
||||||
|
if (!filter_var($credentials['email'], FILTER_VALIDATE_EMAIL)) {
|
||||||
|
if ($profile = $this->profile->findPhoneNumber($credentials['email'])) {
|
||||||
|
if ($user = $this->repository->find($profile->user_no_id)) {
|
||||||
|
$credentials['email'] = $user->email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$response = $this->repository->findByCredentials($credentials);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$response = $authenticator->authenticate($credentials);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response instanceof UserInterface) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response instanceof RedirectResponse) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function handle(SignInFormBuilder $builder)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!$response = $this->authenticate($builder->getPostData())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response instanceof UserInterface) {
|
||||||
|
$builder->setUser($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response instanceof Response) {
|
||||||
|
$builder->setFormResponse($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
<?php namespace Visiosoft\ProfileModule\Profile\Validation;
|
||||||
|
|
||||||
|
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||||
|
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||||
|
|
||||||
|
class ValidateRegister
|
||||||
|
{
|
||||||
|
public function handle(FormBuilder $builder, ProfileRepositoryInterface $profileRepository, $attribute, $value)
|
||||||
|
{
|
||||||
|
if (!filter_var($builder->getPostValue('email'), FILTER_VALIDATE_EMAIL)) {
|
||||||
|
if (!is_numeric($builder->getPostValue('email'))) {
|
||||||
|
$builder->addFormError('email', trans('visiosoft.module.profile::message.error_valid_email_or_phone'));
|
||||||
|
return false;
|
||||||
|
} elseif (!is_null($profileRepository->findPhoneNumber($builder->getPostValue('email')))) {
|
||||||
|
$builder->addFormError('email', trans('visiosoft.module.profile::message.registered_phone'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,6 +14,7 @@ use Anomaly\Streams\Platform\Model\Profile\ProfileProfileEntryModel;
|
|||||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
||||||
use Illuminate\Routing\Router;
|
use Illuminate\Routing\Router;
|
||||||
use Visiosoft\ProfileModule\Profile\Register2\Register2FormBuilder;
|
use Visiosoft\ProfileModule\Profile\Register2\Register2FormBuilder;
|
||||||
|
use Visiosoft\ProfileModule\Profile\SignIn\SignInFormBuilder;
|
||||||
use Visiosoft\ProfileModule\Profile\sites\SitesFormBuilder;
|
use Visiosoft\ProfileModule\Profile\sites\SitesFormBuilder;
|
||||||
use Visiosoft\ProfileModule\Profile\User\UserFormBuilder;
|
use Visiosoft\ProfileModule\Profile\User\UserFormBuilder;
|
||||||
|
|
||||||
@ -175,6 +176,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
|||||||
'updatePassword' => PasswordFormBuilder::class,
|
'updatePassword' => PasswordFormBuilder::class,
|
||||||
'userProfile' => UserFormBuilder::class,
|
'userProfile' => UserFormBuilder::class,
|
||||||
'profile' => ProfileFormBuilder::class,
|
'profile' => ProfileFormBuilder::class,
|
||||||
|
'signIn' => SignInFormBuilder::class,
|
||||||
ProfileAdressEntryModel::class => AdressModel::class,
|
ProfileAdressEntryModel::class => AdressModel::class,
|
||||||
ProfileProfileEntryModel::class => ProfileModel::class,
|
ProfileProfileEntryModel::class => ProfileModel::class,
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user