Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
smart_core_connect
/
core-connect
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51fcd1b7
authored
May 24, 2018
by
Teeradone-PIM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teeradone chage_forgotpassword: ลืมหัสผ่าน change_password: เปลี่ยนรหัสผ่าน
parent
32e0c1de
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
15 deletions
+32
-15
www/src/Controller/UsersController.php
+32
-15
No files found.
www/src/Controller/UsersController.php
View file @
51fcd1b7
...
...
@@ -123,7 +123,6 @@ class UsersController extends AppController {
$this
->
viewBuilder
()
->
layout
(
'blank'
);
}
#---------------------------------------------------------------------------------------------------
#Signup
...
...
@@ -405,6 +404,33 @@ class UsersController extends AppController {
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
if
(
password_verify
(
$oldpassword
,
$users
[
'password'
]))
{
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$this
->
Users
->
save
(
$users
);
$this
->
Flash
->
success
(
__
(
'change password success'
));
return
$this
->
redirect
([
'action'
=>
'signin'
]);
}
else
{
$this
->
Flash
->
error
(
__
(
'Invalid password.'
));
return
$this
->
redirect
([
'action'
=>
'change-password/'
.
$token
]);
}
}
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
}
public
function
change_forgotpassword
(
$token
=
null
)
{
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$users
=
$this
->
Users
->
find
(
'all'
,[
'conditions'
=>
[
'Users.token'
=>
$token
]
])
->
first
();
if
(
$this
->
request
->
is
(
'post'
))
{
$hasher
=
new
DefaultPasswordHasher
();
$password
=
$this
->
request
->
data
[
'password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$this
->
Users
->
save
(
$users
);
$this
->
Flash
->
success
(
__
(
'change password success'
));
...
...
@@ -413,23 +439,14 @@ class UsersController extends AppController {
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
}
#---------------------------------------------------------------------------------------------------
/**
*
* Function user logout / signout
* @author sarawutt.b
* @since 2018/05/22 16:44:20
* @license PAKGON
* @return void
*/
public
function
signout
()
{
$http
=
new
Client
();
$result
=
$http
->
delete
(
Configure
::
read
(
'OAUTH2_PROVIDER.TOKEN_DETETE'
)
.
'/'
.
$this
->
Auth
->
user
(
'id'
))
->
body
();
$this
->
Flash
->
success
(
__
(
'You are now logged out.'
));
return
$this
->
redirect
(
$this
->
Auth
->
logout
());
}
public
function
signout
()
{
$this
->
checkToken
();
}
...
...
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