mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
This commit is contained in:
parent
1f7975207f
commit
ca09129128
@ -48,4 +48,6 @@ return [
|
||||
'popular_ads' => 'Popular Ads',
|
||||
'last_48_hours' => 'Last 48 Hours',
|
||||
'secure_e-commerce_ads' => 'Secure e-Commerce Ads',
|
||||
'sms' => 'Send Text Message (SMS)',
|
||||
'mail' => 'Send Mail',
|
||||
];
|
||||
@ -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.',
|
||||
];
|
||||
@ -35,7 +35,9 @@
|
||||
|
||||
<div>
|
||||
<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">
|
||||
<label class="control-label">
|
||||
<span>
|
||||
@ -63,7 +65,9 @@
|
||||
})|raw }}
|
||||
<div>
|
||||
<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">
|
||||
<label class="control-label">
|
||||
<span>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -13,10 +13,10 @@ class ForgotPassFormFields
|
||||
$builder->setFields(
|
||||
[
|
||||
'email' => [
|
||||
'type' => 'anomaly.field_type.text',
|
||||
'label' => 'anomaly.module.users::field.email.name',
|
||||
'required' => true,
|
||||
'rules' => [
|
||||
'type' => 'anomaly.field_type.text',
|
||||
'label' => 'anomaly.module.users::field.email.name',
|
||||
'required' => true,
|
||||
'rules' => [
|
||||
'valid_email',
|
||||
],
|
||||
'validators' => [
|
||||
@ -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",
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ use Anomaly\Streams\Platform\Message\MessageBag;
|
||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
use Anomaly\UsersModule\User\UserPassword;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Visiosoft\ProfileModule\Profile\Events\SendForgotPasswordSms;
|
||||
|
||||
class ForgotPassFormHandler
|
||||
{
|
||||
@ -12,10 +13,10 @@ class ForgotPassFormHandler
|
||||
* Handle the form.
|
||||
*
|
||||
* @param ForgotPassFormBuilder $builder
|
||||
* @param UserRepositoryInterface $users
|
||||
* @param UserPassword $password
|
||||
* @param MessageBag $messages
|
||||
* @param Repository $config
|
||||
* @param UserRepositoryInterface $users
|
||||
* @param UserPassword $password
|
||||
* @param MessageBag $messages
|
||||
* @param Repository $config
|
||||
*/
|
||||
public function handle(
|
||||
ForgotPassFormBuilder $builder,
|
||||
@ -23,7 +24,8 @@ class ForgotPassFormHandler
|
||||
UserPassword $password,
|
||||
MessageBag $messages,
|
||||
Repository $config
|
||||
) {
|
||||
)
|
||||
{
|
||||
if ($builder->hasFormErrors()) {
|
||||
return;
|
||||
}
|
||||
@ -35,13 +37,25 @@ class ForgotPassFormHandler
|
||||
if ($path = $builder->getFormOption('reset_path')) {
|
||||
$config->set('anomaly.module.users::paths.reset', $path);
|
||||
}
|
||||
|
||||
$password->forgot($user);
|
||||
try {
|
||||
$password->send($user, $builder->getFormOption('reset_redirect'));
|
||||
$messages->success(trans('anomaly.module.users::message.confirm_reset_password'));
|
||||
} catch (\Exception $err) {
|
||||
$messages->error($err->getMessage());
|
||||
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);
|
||||
try {
|
||||
$password->send($user, $builder->getFormOption('reset_redirect'));
|
||||
$messages->success(trans('anomaly.module.users::message.confirm_reset_password'));
|
||||
} catch (\Exception $err) {
|
||||
$messages->error($err->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ class ValidateEmail
|
||||
if (!$response = $users->findByEmail($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$builder->setUser($response);
|
||||
|
||||
return true;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user