Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
d13ed432
Commit
d13ed432
authored
Feb 06, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed signup/restore password flow
parent
9da28421
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
7 deletions
+19
-7
User.php
apps/advanced/common/models/User.php
+10
-0
SiteController.php
apps/advanced/frontend/controllers/SiteController.php
+7
-5
PasswordResetRequestForm.php
apps/advanced/frontend/models/PasswordResetRequestForm.php
+1
-1
SignupForm.php
apps/advanced/frontend/models/SignupForm.php
+1
-1
No files found.
apps/advanced/common/models/User.php
View file @
d13ed432
...
...
@@ -32,6 +32,8 @@ class User extends ActiveRecord implements IdentityInterface
/** @var User $user */
$user
=
new
static
();
$user
->
setAttributes
(
$attributes
);
$user
->
setPassword
(
$attributes
[
'password'
]);
$user
->
generateAuthKey
();
if
(
$user
->
save
())
{
return
$user
;
}
else
{
...
...
@@ -142,6 +144,14 @@ class User extends ActiveRecord implements IdentityInterface
}
/**
* Generates "remember me" authentication key
*/
public
function
generateAuthKey
()
{
$this
->
auth_key
=
Security
::
generateRandomKey
();
}
/**
* Generates new password reset token
*/
public
function
generatePasswordResetToken
()
...
...
apps/advanced/frontend/controllers/SiteController.php
View file @
d13ed432
...
...
@@ -122,11 +122,13 @@ class SiteController extends Controller
public
function
actionRequestPasswordReset
()
{
$model
=
new
PasswordResetRequestForm
();
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
())
&&
$model
->
sendEmail
())
{
Yii
::
$app
->
getSession
()
->
setFlash
(
'success'
,
'Check your email for further instructions.'
);
return
$this
->
goHome
();
}
else
{
Yii
::
$app
->
getSession
()
->
setFlash
(
'error'
,
'There was an error sending email.'
);
if
(
$model
->
load
(
Yii
::
$app
->
request
->
post
()))
{
if
(
$model
->
sendEmail
())
{
Yii
::
$app
->
getSession
()
->
setFlash
(
'success'
,
'Check your email for further instructions.'
);
return
$this
->
goHome
();
}
else
{
Yii
::
$app
->
getSession
()
->
setFlash
(
'error'
,
'Sorry, we are unable to reset password for email provided.'
);
}
}
return
$this
->
render
(
'requestPasswordResetToken'
,
[
...
...
apps/advanced/frontend/models/PasswordResetRequestForm.php
View file @
d13ed432
...
...
@@ -20,7 +20,7 @@ class PasswordResetRequestForm extends Model
[
'email'
,
'filter'
,
'filter'
=>
'trim'
],
[
'email'
,
'required'
],
[
'email'
,
'email'
],
[
'email'
,
'exist'
,
'targetClass'
=>
'User'
,
'message'
=>
'There is no user with such email.'
],
[
'email'
,
'exist'
,
'targetClass'
=>
'
\common\models\
User'
,
'message'
=>
'There is no user with such email.'
],
];
}
...
...
apps/advanced/frontend/models/SignupForm.php
View file @
d13ed432
...
...
@@ -27,7 +27,7 @@ class SignupForm extends Model
[
'email'
,
'filter'
,
'filter'
=>
'trim'
],
[
'email'
,
'required'
],
[
'email'
,
'email'
],
[
'email'
,
'unique'
,
'targetClass'
=>
'User'
,
'message'
=>
'This email address has already been taken.'
],
[
'email'
,
'unique'
,
'targetClass'
=>
'
\common\models\
User'
,
'message'
=>
'This email address has already been taken.'
],
[
'password'
,
'required'
],
[
'password'
,
'string'
,
'min'
=>
6
],
...
...
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