This commit is contained in:
vedatakd 2020-04-26 02:25:41 +03:00
parent 1f7975207f
commit ca09129128
7 changed files with 79 additions and 19 deletions

View File

@ -48,4 +48,6 @@ return [
'popular_ads' => 'Popular Ads', 'popular_ads' => 'Popular Ads',
'last_48_hours' => 'Last 48 Hours', 'last_48_hours' => 'Last 48 Hours',
'secure_e-commerce_ads' => 'Secure e-Commerce Ads', 'secure_e-commerce_ads' => 'Secure e-Commerce Ads',
'sms' => 'Send Text Message (SMS)',
'mail' => 'Send Mail',
]; ];

View File

@ -0,0 +1,6 @@
<?php
return [
'send_forgot_sms' => 'SMS sent to your registered phone. Please check.',
'found_phone' => 'The phone number registered in the system was not found.',
];

View File

@ -35,7 +35,9 @@
<div> <div>
<div class="form-group email-field email-field_type text-center text-md-left"> <div class="form-group email-field email-field_type text-center text-md-left">
<div class="input-wrapper col-12 col-md-5">
{{ form.fields.resetType.input|raw }}
</div>
<div class="input-wrapper col-12 col-md-5"> <div class="input-wrapper col-12 col-md-5">
<label class="control-label"> <label class="control-label">
<span> <span>
@ -63,7 +65,9 @@
})|raw }} })|raw }}
<div> <div>
<div class="form-group email-field email-field_type text-center text-md-left"> <div class="form-group email-field email-field_type text-center text-md-left">
<div class="input-wrapper col-12 col-md-5">
{{ form.fields.resetType.input|raw }}
</div>
<div class="input-wrapper col-12 col-md-5"> <div class="input-wrapper col-12 col-md-5">
<label class="control-label"> <label class="control-label">
<span> <span>

View File

@ -0,0 +1,23 @@
<?php namespace Visiosoft\ProfileModule\Profile\Events;
class SendForgotPasswordSms
{
public $password;
public $user;
public function __construct($user, $password)
{
$this->password = $password;
$this->user = $user;
}
public function user()
{
return $this->user;
}
public function password()
{
return $this->password;
}
}

View File

@ -26,6 +26,18 @@ class ForgotPassFormFields
], ],
], ],
], ],
"resetType" => [
"type" => "anomaly.field_type.select",
"config" => [
"options" => [
'sms' => 'visiosoft.theme.base::field.sms',
'mail' => 'visiosoft.theme.base::field.mail',
],
"separator" => ":",
"default_value" => 'mail',
"mode" => "radio",
]
]
] ]
); );
} }

View File

@ -4,6 +4,7 @@ use Anomaly\Streams\Platform\Message\MessageBag;
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface; use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Anomaly\UsersModule\User\UserPassword; use Anomaly\UsersModule\User\UserPassword;
use Illuminate\Contracts\Config\Repository; use Illuminate\Contracts\Config\Repository;
use Visiosoft\ProfileModule\Profile\Events\SendForgotPasswordSms;
class ForgotPassFormHandler class ForgotPassFormHandler
{ {
@ -23,7 +24,8 @@ class ForgotPassFormHandler
UserPassword $password, UserPassword $password,
MessageBag $messages, MessageBag $messages,
Repository $config Repository $config
) { )
{
if ($builder->hasFormErrors()) { if ($builder->hasFormErrors()) {
return; return;
} }
@ -35,7 +37,18 @@ class ForgotPassFormHandler
if ($path = $builder->getFormOption('reset_path')) { if ($path = $builder->getFormOption('reset_path')) {
$config->set('anomaly.module.users::paths.reset', $path); $config->set('anomaly.module.users::paths.reset', $path);
} }
if ($builder->getPostData()['resetType'] == "sms") {
$user = $users->find($user->id);
$password = str_random(8);
$user->setAttribute('password', $password);
$users->save($user);
if (!is_null($user->gsm_phone)) {
event(new SendForgotPasswordSms($user, $password));
$messages->success(trans('visiosoft.theme.base::message.send_forgot_sms'));
} else {
$messages->error(trans('visiosoft.theme.base::message.found_phone'));
}
} else {
$password->forgot($user); $password->forgot($user);
try { try {
$password->send($user, $builder->getFormOption('reset_redirect')); $password->send($user, $builder->getFormOption('reset_redirect'));
@ -45,3 +58,4 @@ class ForgotPassFormHandler
} }
} }
} }
}

View File

@ -22,7 +22,6 @@ class ValidateEmail
if (!$response = $users->findByEmail($value)) { if (!$response = $users->findByEmail($value)) {
return false; return false;
} }
$builder->setUser($response); $builder->setUser($response);
return true; return true;