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',
|
'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',
|
||||||
];
|
];
|
||||||
@ -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>
|
||||||
<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>
|
||||||
|
|||||||
@ -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(
|
$builder->setFields(
|
||||||
[
|
[
|
||||||
'email' => [
|
'email' => [
|
||||||
'type' => 'anomaly.field_type.text',
|
'type' => 'anomaly.field_type.text',
|
||||||
'label' => 'anomaly.module.users::field.email.name',
|
'label' => 'anomaly.module.users::field.email.name',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'rules' => [
|
'rules' => [
|
||||||
'valid_email',
|
'valid_email',
|
||||||
],
|
],
|
||||||
'validators' => [
|
'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\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
|
||||||
{
|
{
|
||||||
@ -12,10 +13,10 @@ class ForgotPassFormHandler
|
|||||||
* Handle the form.
|
* Handle the form.
|
||||||
*
|
*
|
||||||
* @param ForgotPassFormBuilder $builder
|
* @param ForgotPassFormBuilder $builder
|
||||||
* @param UserRepositoryInterface $users
|
* @param UserRepositoryInterface $users
|
||||||
* @param UserPassword $password
|
* @param UserPassword $password
|
||||||
* @param MessageBag $messages
|
* @param MessageBag $messages
|
||||||
* @param Repository $config
|
* @param Repository $config
|
||||||
*/
|
*/
|
||||||
public function handle(
|
public function handle(
|
||||||
ForgotPassFormBuilder $builder,
|
ForgotPassFormBuilder $builder,
|
||||||
@ -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,13 +37,25 @@ 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") {
|
||||||
$password->forgot($user);
|
$user = $users->find($user->id);
|
||||||
try {
|
$password = str_random(8);
|
||||||
$password->send($user, $builder->getFormOption('reset_redirect'));
|
$user->setAttribute('password', $password);
|
||||||
$messages->success(trans('anomaly.module.users::message.confirm_reset_password'));
|
$users->save($user);
|
||||||
} catch (\Exception $err) {
|
if (!is_null($user->gsm_phone)) {
|
||||||
$messages->error($err->getMessage());
|
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)) {
|
if (!$response = $users->findByEmail($value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->setUser($response);
|
$builder->setUser($response);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user