Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
50aaf4de
Commit
50aaf4de
authored
May 06, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reset password
parent
d4587571
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
150 additions
and
0 deletions
+150
-0
backend/controllers/SiteController.php
backend/controllers/SiteController.php
+22
-0
backend/views/site/reset-password.php
backend/views/site/reset-password.php
+62
-0
common/models/ResetPasswordForm.php
common/models/ResetPasswordForm.php
+66
-0
No files found.
backend/controllers/SiteController.php
View file @
50aaf4de
...
@@ -7,6 +7,7 @@ use yii\web\Controller;
...
@@ -7,6 +7,7 @@ use yii\web\Controller;
use
common\models\LoginForm
;
use
common\models\LoginForm
;
use
common\models\RecoveryForm
;
use
common\models\RecoveryForm
;
use
common\models\ResetPasswordForm
;
use
common\modules\users\models\User
;
use
common\modules\users\models\User
;
/**
/**
...
@@ -110,6 +111,27 @@ class SiteController extends Controller
...
@@ -110,6 +111,27 @@ class SiteController extends Controller
]);
]);
}
}
public
function
actionResetPassword
(
$token
)
{
$success
=
false
;
try
{
$model
=
new
ResetPasswordForm
(
$token
);
}
catch
(
InvalidParamException
$e
)
{
throw
new
BadRequestHttpException
(
$e
->
getMessage
());
}
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
validate
()
&&
$model
->
resetPassword
())
{
$success
=
true
;
}
return
$this
->
render
(
'reset-password'
,
[
'model'
=>
$model
,
'success'
=>
$success
,
]);
}
public
function
actionLogout
()
public
function
actionLogout
()
{
{
Yii
::
$app
->
user
->
logout
();
Yii
::
$app
->
user
->
logout
();
...
...
backend/views/site/reset-password.php
0 → 100644
View file @
50aaf4de
<?php
use
yii\helpers\Html
;
use
yii\bootstrap\ActiveForm
;
?>
<!-- begin login -->
<div
class=
"login login-v2"
data-pageload-addclass=
"animated flipInX"
>
<!-- begin brand -->
<div
class=
"login-header"
>
<div
class=
"brand"
>
<img
src=
"/img/logo.png"
>
<small>
Востановление пароля
</small>
</div>
<div
class=
"icon"
>
<i
class=
"fa fa-sign-in"
></i>
</div>
</div>
<!-- end brand -->
<div
class=
"login-content"
>
<?php
if
(
$success
)
:
?>
<center>
Новый пароль успешно сохранен.
<br>
<?=
Html
::
a
(
'Вернуться к авторизации'
,
[
'login'
])
?>
</center>
<?php
else
:
?>
<?php
$form
=
ActiveForm
::
begin
([
'enableClientValidation'
=>
true
,
'id'
=>
'login-form'
,
'options'
=>
[
'class'
=>
'margin-bottom-0'
],
'fieldConfig'
=>
[
'template'
=>
'{input}{error}'
,
],
]);
?>
<div
class=
"form-group m-b-20"
>
<?=
$form
->
field
(
$model
,
'password'
,
[
'inputOptions'
=>
[
'class'
=>
'form-control input-lg'
,
'placeholder'
=>
'Введите новый пароль'
,
]
]
)
->
passwordInput
()
->
label
(
false
)
?>
</div>
<div
class=
"login-buttons"
>
<?=
Html
::
submitButton
(
'Сохранить'
,
[
'class'
=>
'btn btn-success btn-block btn-lg'
,
'name'
=>
'login-button'
])
?>
</div>
<?php
ActiveForm
::
end
();
?>
<?php
endif
;
?>
</div>
</div>
<!-- end login -->
<?php
$this
->
registerJsFile
(
'/js/login-v2.demo.min.js'
,
[
'position'
=>
\yii\web\View
::
POS_END
]);
$this
->
registerJs
(
'App.init();LoginV2.init();'
,
\yii\web\View
::
POS_READY
);
?>
\ No newline at end of file
common/models/ResetPasswordForm.php
0 → 100644
View file @
50aaf4de
<?php
namespace
common\models
;
use
Yii
;
use
yii\base\InvalidParamException
;
use
yii\base\Model
;
use
common\modules\users\models\User
;
/**
* Password reset form
*/
class
ResetPasswordForm
extends
Model
{
public
$password
;
/**
* @var \common\models\User
*/
private
$_user
;
/**
* Creates a form model given a token.
*
* @param string $token
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if token is empty or not valid
*/
public
function
__construct
(
$token
,
$config
=
[])
{
if
(
empty
(
$token
)
||
!
is_string
(
$token
))
{
throw
new
InvalidParamException
(
'Password reset token cannot be blank.'
);
}
$this
->
_user
=
User
::
findByPasswordResetToken
(
$token
);
if
(
!
$this
->
_user
)
{
throw
new
InvalidParamException
(
'Wrong password reset token.'
);
}
parent
::
__construct
(
$config
);
}
/**
* @inheritdoc
*/
public
function
rules
()
{
return
[
[
'password'
,
'required'
],
[
'password'
,
'string'
,
'min'
=>
7
],
];
}
/**
* Resets password.
*
* @return boolean if password was reset.
*/
public
function
resetPassword
()
{
$user
=
$this
->
_user
;
$user
->
setPassword
(
$this
->
password
);
$user
->
removePasswordResetToken
();
return
$user
->
save
(
false
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment