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
7785f907
authored
May 24, 2018
by
Prasong Putichanchai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update user
parent
2faaee2b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
21 deletions
+42
-21
www/src/Controller/ProfilesController.php
+6
-1
www/src/Controller/UsersController.php
+35
-19
www/src/Template/Users/change_forgotpassword.ctp
+1
-1
No files found.
www/src/Controller/ProfilesController.php
View file @
7785f907
...
@@ -53,7 +53,12 @@ class ProfilesController extends AppController
...
@@ -53,7 +53,12 @@ class ProfilesController extends AppController
if
(
!
empty
(
$Province
))
$Province
=
$Province
->
toArray
();
if
(
!
empty
(
$Province
))
$Province
=
$Province
->
toArray
();
$res
=
$responseUserPersonal
[
'birthdate'
];
$res
=
$responseUserPersonal
[
'birthdate'
];
$dateNow
=
$res
->
i18nFormat
(
'dd/MM/yyyy'
);
if
(
$res
){
$dateNow
=
@
$res
->
i18nFormat
(
'dd/MM/yyyy'
);
}
else
{
$dateNow
=
""
;
}
if
(
$this
->
request
->
is
([
'patch'
,
'post'
,
'put'
]))
{
if
(
$this
->
request
->
is
([
'patch'
,
'post'
,
'put'
]))
{
$data
=
$this
->
request
->
data
;
$data
=
$this
->
request
->
data
;
...
...
www/src/Controller/UsersController.php
View file @
7785f907
...
@@ -18,7 +18,7 @@ class UsersController extends AppController {
...
@@ -18,7 +18,7 @@ class UsersController extends AppController {
*/
*/
public
function
initialize
()
{
public
function
initialize
()
{
parent
::
initialize
();
parent
::
initialize
();
$this
->
Auth
->
allow
([
'signin'
,
'signout'
,
'signup'
,
'verify'
,
'forgotPassword'
,
'createAccount'
,
'pinCode'
,
'pinCodepassword'
]);
$this
->
Auth
->
allow
([
'signin'
,
'signout'
,
'signup'
,
'verify'
,
'forgotPassword'
,
'createAccount'
,
'pinCode'
,
'pinCodepassword'
,
'changeForgotpassword'
]);
}
}
public
function
index
()
{
public
function
index
()
{
...
@@ -117,12 +117,13 @@ class UsersController extends AppController {
...
@@ -117,12 +117,13 @@ class UsersController extends AppController {
'keyField'
=>
'id'
,
'keyField'
=>
'id'
,
'valueField'
=>
'province_name_th'
'valueField'
=>
'province_name_th'
]
]
);
);
if
(
!
empty
(
$provinces
))
$provinces
=
$provinces
->
toArray
();
if
(
!
empty
(
$provinces
))
$provinces
=
$provinces
->
toArray
();
$this
->
set
(
compact
(
'provinces'
,
'countries'
));
$this
->
set
(
compact
(
'provinces'
,
'countries'
));
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
}
}
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
#Signup
#Signup
...
@@ -382,7 +383,7 @@ class UsersController extends AppController {
...
@@ -382,7 +383,7 @@ class UsersController extends AppController {
$data
[
'pin_pass'
]
=
$data
[
'pin_code_1'
]
.
$data
[
'pin_code_2'
]
.
$data
[
'pin_code_3'
]
.
$data
[
'pin_code_4'
];
$data
[
'pin_pass'
]
=
$data
[
'pin_code_1'
]
.
$data
[
'pin_code_2'
]
.
$data
[
'pin_code_3'
]
.
$data
[
'pin_code_4'
];
if
(
$data
[
'pin_pass'
]
==
$users
[
'pin_pass'
]){
if
(
$data
[
'pin_pass'
]
==
$users
[
'pin_pass'
]){
$this
->
Flash
->
success
(
__
(
'Pin Completed.'
));
$this
->
Flash
->
success
(
__
(
'Pin Completed.'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'change
P
assword/'
.
$token
]);
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'change
Forgotp
assword/'
.
$token
]);
}
}
$this
->
Flash
->
error
(
__
(
'Pin Invalid'
));
$this
->
Flash
->
error
(
__
(
'Pin Invalid'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'pinCodepassword/'
.
$token
]);
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'pinCodepassword/'
.
$token
]);
...
@@ -392,32 +393,37 @@ class UsersController extends AppController {
...
@@ -392,32 +393,37 @@ class UsersController extends AppController {
public
function
changePassword
(
$token
=
null
)
public
function
changePassword
(
$token
=
null
)
{
{
$id
=
$this
->
Auth
->
user
(
'id'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$users
=
$this
->
Users
->
find
(
'all'
,[
$users
=
$this
->
Users
->
get
(
$id
);
'conditions'
=>
[
'Users.token'
=>
$token
]
])
->
first
();
if
(
$this
->
request
->
is
(
'post'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
$hasher
=
new
DefaultPasswordHasher
();
$hasher
=
new
DefaultPasswordHasher
();
$password
=
$this
->
request
->
data
[
'password'
];
$password
=
$this
->
request
->
data
[
'password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
$oldpassword
=
$this
->
request
->
data
[
'oldpassword'
];
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
if
(
password_verify
(
$oldpassword
,
$users
[
'password'
]))
{
if
(
password_verify
(
$oldpassword
,
$users
[
'password'
]))
{
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$this
->
Users
->
save
(
$users
);
$this
->
Users
->
save
(
$users
);
$this
->
Flash
->
success
(
__
(
'change password success'
));
$this
->
Flash
->
success
(
__
(
'change password success'
));
return
$this
->
redirect
([
'action'
=>
'signin'
]);
$this
->
Flash
->
success
(
__
(
'You are now logged out.'
));
return
$this
->
redirect
([
'action'
=>
'signout'
]);
}
else
{
}
else
{
$this
->
Flash
->
error
(
__
(
'Invalid password.'
));
$this
->
Flash
->
error
(
__
(
'Invalid password.'
));
return
$this
->
redirect
([
'action'
=>
'change-password
/'
.
$token
]);
return
$this
->
redirect
([
'action'
=>
'change-password
'
]);
}
}
}
}
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
}
}
public
function
change
_f
orgotpassword
(
$token
=
null
)
public
function
change
F
orgotpassword
(
$token
=
null
)
{
{
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$users
=
$this
->
Users
->
find
(
'all'
,[
$users
=
$this
->
Users
->
find
(
'all'
,[
...
@@ -428,7 +434,7 @@ class UsersController extends AppController {
...
@@ -428,7 +434,7 @@ class UsersController extends AppController {
if
(
$this
->
request
->
is
(
'post'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
$hasher
=
new
DefaultPasswordHasher
();
$hasher
=
new
DefaultPasswordHasher
();
$password
=
$this
->
request
->
data
[
'password'
];
$password
=
$this
->
request
->
data
[
'password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
//
$confirm_password = $this->request->data['confirm_password'];
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$this
->
request
->
data
[
'password'
]);
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
//------- เทียบ password ที่เข้ารหัส ---------------password_verify($password,hashed_password)---------------------------
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
...
@@ -442,11 +448,21 @@ class UsersController extends AppController {
...
@@ -442,11 +448,21 @@ class UsersController extends AppController {
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
public
function
signout
()
/**
{
*
$this
->
checkToken
();
* 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
());
}
...
...
www/src/Template/Users/change_forgotpassword.ctp
View file @
7785f907
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<!-- <div class="alert alert-warning" role="alert" style="margin: 10px 0px 10px 0px;font-size: 17px;text-align: center;">
<!-- <div class="alert alert-warning" role="alert" style="margin: 10px 0px 10px 0px;font-size: 17px;text-align: center;">
<strong><?php echo __('กรุณา! ตรวจสอบอีเมลล์ของท่าน');?></strong>
<strong><?php echo __('กรุณา! ตรวจสอบอีเมลล์ของท่าน');?></strong>
</div>-->
</div>-->
<?php echo $this->Form->create(null, ['url' => ['controller' => 'Users','action' => 'change
P
assword/'.$token],'class' => 'form-horizontal','id' => '','name' => 'changeForgotpassword','role' => 'form', 'onsubmit' => 'return validateForm()']);?>
<?php echo $this->Form->create(null, ['url' => ['controller' => 'Users','action' => 'change
Forgotp
assword/'.$token],'class' => 'form-horizontal','id' => '','name' => 'changeForgotpassword','role' => 'form', 'onsubmit' => 'return validateForm()']);?>
<?php echo $this->Flash->render(); ?>
<?php echo $this->Flash->render(); ?>
</div>
</div>
<div>
<div>
...
...
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