#931 Forget Password Design and SMS

This commit is contained in:
Diatrex 2020-03-17 16:34:46 +03:00
parent 567f84c813
commit 4e8f1ea9a4
11 changed files with 223 additions and 52 deletions

View File

@ -0,0 +1,25 @@
@media only screen and (min-width: 768px) {
.forgot-wrapper {
padding-top: 4em;
padding-bottom: 4em;
padding-left: 4.25em;
border: 1px solid #dee2e6!important;
}
}
@media only screen and (min-width: 768px) {
.forgot-form-wrapper {
width: 20em !important;
}
}
.forgot-img {
height: 11em;
width: 10em;
}
.forgot-wrapper label {
font-size: 14px;
}
@media only screen and (min-width: 768px) {
.forgot-form-wrapper button {
width: initial !important;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -30,4 +30,7 @@ return [
'personal_registration_list_2' => 'Add the ads you are interested in, follow the price changes after adding them to your favorites, create favorite searches that meet your criteria,',
'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.',
// Forgot Password
'create_new_password' => 'Create New Password',
];

View File

@ -1,21 +1,27 @@
{% extends "theme::layouts/default" %}
{% block content %}
<div class="row justify-content-center">
<div class="col-12 col-sm-8 col-md-6 col-lg-4 text-left bg-light p-3 m-0">
{% set form = form('forgot_password').redirect(request_get('redirect', '/'))
<div class="d-flex mt-4 forgot-wrapper">
<div class="d-none d-md-block">
<img src="{{ img('visiosoft.theme.base::images/forgot-password.png').url }}" class="forgot-img"
alt="forgot password icon">
</div>
<div class="m-0 ml-md-5 forgot-form-wrapper w-100">
{% set form = form('forgot_pass').redirect(request_get('redirect', '/'))
.get() %}
{{ form_open({
'class': 'row form ' ~ form.options.class ,
'class': 'form ' ~ form.options.class ,
'url':form.options.url
})|raw }}
<div class="col-12">
<h4>{{ trans('visiosoft.theme.base::field.forgot_password') }}</h4>
<div class="form-group email-field email-field_type">
<label class="control-label">
{{ trans('visiosoft.theme.base::field.email') }}
<div>
<h5 class="d-none d-md-block">{{ trans('visiosoft.theme.base::field.create_new_password') }}</h5>
<div class="form-group email-field email-field_type text-center text-md-left">
<label class="control-label mb-3 mb-md-0">
<span>
{{ trans('visiosoft.theme.base::field.email_or_phone_number') }}
</span>
<span class="required">*</span>
</label>
@ -25,11 +31,12 @@
</div>
</div>
<div class="col-12 row m-0">
<button class="btn btn-sm btn-primary w-100 py-2">
<div class="m-0">
<button class="btn btn-sm btn-primary py-2 px-5 w-100">
{{ trans('visiosoft.theme.base::button.continue') }}
</button>
</div>
</div>
</div>
{{ asset_add('styles.css', 'visiosoft.theme.base::css/forgot.css') }}
{% endblock %}

View File

@ -1,44 +1,24 @@
{% extends "theme::layouts/default" %}
{% block content %}
<div class="row justify-content-center">
<div class="col-12 col-sm-8 col-md-6 col-lg-4 text-left bg-light p-3 m-0">
<div class="d-flex mt-4 forgot-wrapper">
<div class="d-none d-md-block">
<img src="{{ img('visiosoft.theme.base::images/forgot-password.png').url }}" class="forgot-img"
alt="forgot password icon">
</div>
<div class="m-0 ml-md-5 forgot-form-wrapper w-100">
{% set form = form('reset_password').redirect(request_get('redirect', '/'))
.get() %}
{{ form_open({
'class': 'row form ' ~ form.options.class ,
'class': 'form ' ~ form.options.class ,
'url':form.options.url
})|raw }}
<div class="col-12">
<h4>{{ trans('visiosoft.theme.base::button.reset_password') }}</h4>
<div class="form-group email-field email-field_type">
<label class="control-label">
{{ trans('visiosoft.theme.base::field.email') }}
<span class="required">*</span>
</label>
<div class="input-wrapper">
{{ form.fields.email.input|raw }}
</div>
</div>
</div>
<div class="col-12">
<div class="form-group email-field code-field_type">
<label class="control-label">
{{ trans('visiosoft.theme.base::field.reset_code') }}
<span class="required">*</span>
</label>
<div class="input-wrapper">
{{ form.fields.code.input|raw }}
</div>
</div>
</div>
<div class="col-12">
<div class="form-group email-field password-field_type">
<label class="control-label">
<div>
<h5 class="d-none d-md-block">{{ trans('visiosoft.theme.base::field.create_new_password') }}</h5>
<div class="form-group email-field password-field_type mb-2 text-center text-md-left">
<label class="control-label mb-0">
{{ trans('visiosoft.theme.base::field.password') }}
<span class="required">*</span>
</label>
@ -46,11 +26,8 @@
<div class="input-wrapper">
{{ form.fields.password.input|raw }}
</div>
</div>
</div>
<div class="col-12">
<div class="form-group email-field password_confirmation-field_type">
<label class="control-label">
</div><div class="form-group email-field password_confirmation-field_type text-center text-md-left">
<label class="control-label mb-0">
{{ trans('visiosoft.theme.base::field.password_confirmation') }}
<span class="required">*</span>
</label>
@ -61,11 +38,12 @@
</div>
</div>
<div class="col-12 row m-0">
<button class="btn btn-sm btn-primary w-100 py-2">
{{ trans('visiosoft.theme.base::button.reset_password') }}
<div class="m-0 text-center text-md-left">
<button class="btn btn-sm btn-primary py-2 px-3">
{{ trans('visiosoft.theme.base::button.continue') }}
</button>
</div>
</div>
</div>
{{ asset_add('styles.css', 'visiosoft.theme.base::css/forgot.css') }}
{% endblock %}

View File

@ -27,4 +27,7 @@ return [
'registered_phone' => 'This phone number has already been registered.',
'ajax_address_error' => 'No address or not authorized to view.',
'empty_password_sms_message' => 'Due to security issues, we changed your password! Your new password is:',
// Forgot Password
'email_phone_not_found' => 'The E-mail, Phone Number is not correct!'
];

View File

@ -0,0 +1,47 @@
<?php namespace Visiosoft\ProfileModule\Profile\Password;
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
use Anomaly\UsersModule\User\Contract\UserInterface;
class ForgotPassFormBuilder extends FormBuilder
{
protected $user = null;
/**
* No model.
*
* @var bool
*/
protected $model = false;
/**
* The form actions.
*
* @var array
*/
protected $actions = [
'submit',
];
/**
* The form options.
*
* @var array
*/
protected $options = [
'redirect' => '/',
'success_message' => 'anomaly.module.users::message.confirm_reset_password',
];
public function getUser()
{
return $this->user;
}
public function setUser(UserInterface $user)
{
$this->user = $user;
return $this;
}
}

View File

@ -0,0 +1,32 @@
<?php namespace Visiosoft\ProfileModule\Profile\Password;
class ForgotPassFormFields
{
/**
* Handle the fields.
*
* @param ForgotPassFormBuilder $builder
*/
public function handle(ForgotPassFormBuilder $builder)
{
$builder->setFields(
[
'email' => [
'type' => 'anomaly.field_type.text',
'label' => 'anomaly.module.users::field.email.name',
'required' => true,
'rules' => [
'valid_email',
],
'validators' => [
'valid_email' => [
'handler' => 'Visiosoft\ProfileModule\Profile\Validation\ValidateEmail@handle',
'message' => 'visiosoft.module.profile::message.email_phone_not_found',
],
],
],
]
);
}
}

View File

@ -0,0 +1,44 @@
<?php namespace Visiosoft\ProfileModule\Profile\Password;
use Anomaly\Streams\Platform\Message\MessageBag;
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Anomaly\UsersModule\User\UserPassword;
use Illuminate\Contracts\Config\Repository;
class ForgotPassFormHandler
{
/**
* Handle the form.
*
* @param ForgotPassFormBuilder $builder
* @param UserRepositoryInterface $users
* @param UserPassword $password
* @param MessageBag $messages
* @param Repository $config
*/
public function handle(
ForgotPassFormBuilder $builder,
UserRepositoryInterface $users,
UserPassword $password,
MessageBag $messages,
Repository $config
) {
if ($builder->hasFormErrors()) {
return;
}
if (!$user = $builder->getUser()) {
return;
}
if ($path = $builder->getFormOption('reset_path')) {
$config->set('anomaly.module.users::paths.reset', $path);
}
$password->forgot($user);
$password->send($user, $builder->getFormOption('reset_redirect'));
$messages->success($builder->getFormOption('success_message'));
}
}

View File

@ -0,0 +1,30 @@
<?php namespace Visiosoft\ProfileModule\Profile\Validation;
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Visiosoft\ProfileModule\Profile\Password\ForgotPassFormBuilder;
class ValidateEmail
{
public function handle(UserRepositoryInterface $users, $value, ForgotPassFormBuilder $builder)
{
//Is email or phone number
if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
$possiblePhone = $value;
if (substr($value, 0, 1) == 0) {
$possiblePhone = substr($value, 1);
}
if ($user = $users->newQuery()
->where('gsm_phone', 'LIKE', "%$possiblePhone")->first()) {
$value = $user->email;
}
}
if (!$response = $users->findByEmail($value)) {
return false;
}
$builder->setUser($response);
return true;
}
}

View File

@ -6,6 +6,7 @@ use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
use Visiosoft\ProfileModule\Adress\AdressRepository;
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
use Visiosoft\ProfileModule\Adress\AdressModel;
use Visiosoft\ProfileModule\Profile\Password\ForgotPassFormBuilder;
use Visiosoft\ProfileModule\Profile\Password\PasswordFormBuilder;
use Visiosoft\ProfileModule\Profile\Profile\ProfileFormBuilder;
use Illuminate\Routing\Router;
@ -194,6 +195,7 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
AdressRepositoryInterface::class => AdressRepository::class,
'register2' => Register2FormBuilder::class,
'sites' => SitesFormBuilder::class,
'forgot_pass' => ForgotPassFormBuilder::class,
];
/**