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
1f2c42df
authored
May 31, 2018
by
Prasong Putichanchai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update user con
parent
c06a328c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
296 additions
and
215 deletions
+296
-215
www/src/Controller/AppController.php
+14
-0
www/src/Controller/UsersController.php
+257
-190
www/src/Template/Layout/blank.ctp
+21
-20
www/src/Template/Profiles/index.ctp
+4
-5
No files found.
www/src/Controller/AppController.php
View file @
1f2c42df
...
@@ -92,10 +92,24 @@ class AppController extends Controller {
...
@@ -92,10 +92,24 @@ class AppController extends Controller {
$this
->
request
->
session
()
->
write
(
'SessionLanguage'
,
'tha'
);
$this
->
request
->
session
()
->
write
(
'SessionLanguage'
,
'tha'
);
}
}
$this
->
checkSessionAuth
();
$this
->
Auth
->
allow
([
'signin'
,
'signout'
,
'signup'
,
'verify'
]);
$this
->
Auth
->
allow
([
'signin'
,
'signout'
,
'signup'
,
'verify'
]);
}
}
/**
/**
*
* Function check for session
* @author sarawutt.b
* @return void
*/
public
function
checkSessionAuth
()
{
$currentPath
=
strtolower
(
trim
(
$this
->
request
->
here
));
if
(
!
empty
(
$this
->
Auth
->
user
(
'id'
))
&&
(
$currentPath
==
'/'
))
{
return
$this
->
redirect
(
Configure
::
read
(
'RedirectApplicationURL'
));
}
}
/**
* Before render callback.
* Before render callback.
*
*
* @param \Cake\Event\Event $event The beforeRender event.
* @param \Cake\Event\Event $event The beforeRender event.
...
...
www/src/Controller/UsersController.php
View file @
1f2c42df
...
@@ -18,22 +18,34 @@ class UsersController extends AppController {
...
@@ -18,22 +18,34 @@ 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', 'changeForgotpassword']);
$this
->
Auth
->
allow
([
'signin'
,
'signout'
,
'signup'
,
'verify'
,
'forgotPassword'
,
'createAccount'
,
'pinCode'
,
'pinCodepassword'
,
'registersendpin'
,
'forgotsendpin'
,
'changeForgotpassword'
]);
$this
->
Auth
->
allow
([
'signin'
,
'signout'
,
'signup'
,
'verify'
,
'forgotPassword'
,
'createAccount'
,
'pinCode'
,
'pinCodepassword'
,
'registersendpin'
,
'forgotsendpin'
,
'changeForgotpassword'
]);
}
}
public
function
index
()
{
public
function
index
()
{
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'signin'
]);
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'signin'
]);
}
}
/**
*
* Function signin / login make for user authentication
* @author sarawutt.b
* @since 20108/05/24 10:49:20
* @license Pakgon
* @return void
*/
public
function
signin
()
{
public
function
signin
()
{
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
}
}
#Signin
#Signin
public
function
verify
()
{
public
function
verify
()
{
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
if
(
$this
->
request
->
is
(
'post'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
$data
=
$this
->
request
->
getData
();
$data
=
$this
->
request
->
getData
();
if
(
!
empty
(
$data
))
{
if
(
!
empty
(
$data
))
{
...
@@ -42,7 +54,7 @@ class UsersController extends AppController {
...
@@ -42,7 +54,7 @@ class UsersController extends AppController {
$http
=
new
Client
();
$http
=
new
Client
();
$response
=
$http
->
post
(
$api_core_signin
,
$data
[
'data'
])
->
body
();
$response
=
$http
->
post
(
$api_core_signin
,
$data
[
'data'
])
->
body
();
$response
=
json_decode
(
$response
,
'_full'
);
$response
=
json_decode
(
$response
,
'_full'
);
if
(
!
empty
(
$response
))
{
if
(
!
empty
(
$response
))
{
if
(
strtolower
(
trim
(
$response
[
'status'
]))
==
'success'
)
{
if
(
strtolower
(
trim
(
$response
[
'status'
]))
==
'success'
)
{
$response
[
'result'
][
'user'
][
'id'
]
=
$response
[
'result'
][
'user'
][
'user_id'
];
$response
[
'result'
][
'user'
][
'id'
]
=
$response
[
'result'
][
'user'
][
'user_id'
];
...
@@ -50,14 +62,12 @@ class UsersController extends AppController {
...
@@ -50,14 +62,12 @@ class UsersController extends AppController {
//$url = Router::url(['controller' => 'Homes', 'action' => 'index'], true);
//$url = Router::url(['controller' => 'Homes', 'action' => 'index'], true);
// Before chan logic to OAUTH
// Before chan logic to OAUTH
// echo "<script>setTimeout(function(){Login.onLogin('" . $response['result']['token'] . "','" . $url . "','" . $response['result']['topic'] . "')},1000);</script>";
// echo "<script>setTimeout(function(){Login.onLogin('" . $response['result']['token'] . "','" . $url . "','" . $response['result']['topic'] . "')},1000);</script>";
$statusCode
=
'200'
;
$statusCode
=
'200'
;
// echo "<script type='text/javascript'>setTimeout(function(){Login.onLogin('" . $statusCode . "','" . $this->_redirectApplicationURL . "','" . $response['result']['topic'] . "')},1000);</script>";
// echo "<script type='text/javascript'>setTimeout(function(){Login.onLogin('" . $statusCode . "','" . $this->_redirectApplicationURL . "','" . $response['result']['topic'] . "')},1000);</script>";
$redirectApplicationURL
=
Configure
::
read
(
'RedirectApplicationURL'
);
$RedirectApplicationURL
=
Configure
::
read
(
'RedirectApplicationURL'
);
$topic
=
$response
[
'result'
][
'topic'
];
$topic
=
$response
[
'result'
][
'topic'
];
$this
->
set
(
compact
(
'statusCode'
,
'redirectApplicationURL'
,
'topic'
));
$token
=
$response
[
'result'
][
'token'
];
$this
->
set
(
compact
(
'statusCode'
,
'RedirectApplicationURL'
,
'topic'
,
'token'
));
#echo "<script>setTimeout(function(){alert('".$response['result']['token']."')},1000);</script>";
#echo "<script>setTimeout(function(){alert('".$response['result']['token']."')},1000);</script>";
#echo "<script>Login.onLogin('".$response['result']['token']."','".$url."','".$response['result']['topic']."');</script>";
#echo "<script>Login.onLogin('".$response['result']['token']."','".$url."','".$response['result']['topic']."');</script>";
...
@@ -82,6 +92,7 @@ class UsersController extends AppController {
...
@@ -82,6 +92,7 @@ class UsersController extends AppController {
#------------------------------------------------------------------
#------------------------------------------------------------------
//$this->redirect($this->_redirectApplicationURL);
//$this->redirect($this->_redirectApplicationURL);
//header('Location: ' . $this->_redirectApplicationURL);
//header('Location: ' . $this->_redirectApplicationURL);
//return $this->redirect($redirectApplicationURL);
}
else
{
}
else
{
$this
->
Flash
->
error
(
__
(
'Verify Fail'
));
$this
->
Flash
->
error
(
__
(
'Verify Fail'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'signin'
]);
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'signin'
]);
...
@@ -97,10 +108,9 @@ class UsersController extends AppController {
...
@@ -97,10 +108,9 @@ class UsersController extends AppController {
}
}
}
}
public
function
signup
()
public
function
signup
()
{
{
$this
->
loadModel
(
'MasterCountries'
);
$this
->
loadModel
(
'MasterCountries'
);
$this
->
loadModel
(
'MasterProvinces'
);
$this
->
loadModel
(
'MasterProvinces'
);
$countries
=
$this
->
MasterCountries
->
find
(
'list'
,
$countries
=
$this
->
MasterCountries
->
find
(
'list'
,
[
[
...
@@ -127,132 +137,126 @@ class UsersController extends AppController {
...
@@ -127,132 +137,126 @@ class UsersController extends AppController {
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
#Signup
#Signup
public
function
createAccount
()
{
public
function
createAccount
()
{
$this
->
loadModel
(
'UserPersonals'
);
$this
->
loadModel
(
'UserPersonals'
);
$users
=
$this
->
Users
->
newEntity
();
$users
=
$this
->
Users
->
newEntity
();
$user_personals
=
$this
->
UserPersonals
->
newEntity
();
$user_personals
=
$this
->
UserPersonals
->
newEntity
();
if
(
$this
->
request
->
is
(
'post'
))
{
if
(
$this
->
request
->
is
(
'post'
))
{
// $username_check = $this->MasterProvinces->find('all')->toArray();
// $username_check = $this->MasterProvinces->find('all')->toArray();
// pr($username_check);die;
// pr($username_check);die;
// pr($this->request->data);die;
// pr($this->request->data);die;
$today
=
Time
::
now
();
$today
=
Time
::
now
();
$dateNow
=
$today
->
i18nFormat
(
'yyyy-MM-dd HH:mm:ss'
);
$dateNow
=
$today
->
i18nFormat
(
'yyyy-MM-dd HH:mm:ss'
);
$hasher
=
new
DefaultPasswordHasher
();
$hasher
=
new
DefaultPasswordHasher
();
$firstname
=
$this
->
request
->
data
[
'firstname'
];
$firstname
=
$this
->
request
->
data
[
'firstname'
];
// $phone_no = $this->request->data['phone_no'];
// $phone_no = $this->request->data['phone_no'];
$lastname
=
$this
->
request
->
data
[
'lastname'
];
$lastname
=
$this
->
request
->
data
[
'lastname'
];
$master_country_id
=
$this
->
request
->
data
[
'master_country_id'
];
$master_country_id
=
$this
->
request
->
data
[
'master_country_id'
];
$master_province_id
=
$this
->
request
->
data
[
'master_province_id'
];
$master_province_id
=
$this
->
request
->
data
[
'master_province_id'
];
$password
=
$this
->
request
->
data
[
'password'
];
$password
=
$this
->
request
->
data
[
'password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
$btn
=
$this
->
request
->
data
[
'btn'
];
$btn
=
$this
->
request
->
data
[
'btn'
];
if
(
!
empty
(
$this
->
request
->
data
[
'birthdate'
]))
{
if
(
!
empty
(
$this
->
request
->
data
[
'birthdate'
]))
{
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'birthdate'
]);
$birthdate
=
explode
(
"/"
,
$this
->
request
->
data
[
'birthdate'
]);
$birthdate
=
$birthdate
[
2
]
.
'-'
.
$birthdate
[
1
]
.
'-'
.
$birthdate
[
0
];
$birthdate
=
$birthdate
[
2
]
.
'-'
.
$birthdate
[
1
]
.
'-'
.
$birthdate
[
0
];
$this
->
request
->
data
[
'birthdate'
]
=
$birthdate
;
$this
->
request
->
data
[
'birthdate'
]
=
$birthdate
;
}
else
{
}
else
{
$birthdate
=
'2000-10-10'
;
$birthdate
=
'2000-10-10'
;
}
}
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$password
);
$this
->
request
->
data
[
'password'
]
=
$hasher
->
hash
(
$password
);
$users
[
'created_by'
]
=
0
;
$users
[
'created_by'
]
=
0
;
$users
[
'is_used'
]
=
false
;
$users
[
'is_used'
]
=
false
;
$users
[
'created'
]
=
$dateNow
;
$users
[
'created'
]
=
$dateNow
;
$users
[
'dynamic_key'
]
=
'dynamic_key'
;
$users
[
'dynamic_key'
]
=
'dynamic_key'
;
// $users['point'] = 0;
// $users['point'] = 0;
$users
[
'dynamic_key_expiry'
]
=
date
(
'Y-m-d'
,
strtotime
(
'+3 day'
));
$users
[
'dynamic_key_expiry'
]
=
date
(
'Y-m-d'
,
strtotime
(
'+3 day'
));
$users
[
'token'
]
=
Security
::
hash
(
$this
->
request
->
data
[
'username'
]
.
date
(
'Y-m-d h:i:s'
),
'md5'
,
true
);
$users
[
'token'
]
=
Security
::
hash
(
$this
->
request
->
data
[
'username'
]
.
date
(
'Y-m-d h:i:s'
),
'md5'
,
true
);
$users
[
'token_expiry'
]
=
date
(
'Y-m-d'
,
strtotime
(
'+3 day'
));
$users
[
'token_expiry'
]
=
date
(
'Y-m-d'
,
strtotime
(
'+3 day'
));
// $users['modified_by'] = $modified_by;
// $users['modified_by'] = $modified_by;
$digits
=
4
;
$digits
=
4
;
$users
[
'pin_code'
]
=
str_pad
(
rand
(
0
,
pow
(
10
,
$digits
)
-
1
),
$digits
,
'0'
,
STR_PAD_LEFT
);
$users
[
'pin_code'
]
=
str_pad
(
rand
(
0
,
pow
(
10
,
$digits
)
-
1
),
$digits
,
'0'
,
STR_PAD_LEFT
);
if
(
!
empty
(
$this
->
request
->
data
[
'accept'
])){
if
(
!
empty
(
$this
->
request
->
data
[
'accept'
]))
{
$username_check
=
$this
->
Users
->
find
(
'all'
,[
$username_check
=
$this
->
Users
->
find
(
'all'
,
[
'conditions'
=>
[
'conditions'
=>
[
'Users.username'
=>
$this
->
request
->
data
[
'username'
]
'Users.username'
=>
$this
->
request
->
data
[
'username'
]
]
]
])
->
toArray
();
])
->
toArray
();
$email_check
=
$this
->
UserPersonals
->
find
(
'all'
,[
'conditions'
=>
[
'UserPersonals.email'
=>
$this
->
request
->
data
[
'email'
]
]
])
->
toArray
();
if
((
empty
(
$username_check
))
&&
(
empty
(
$email_check
))){
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
// pr($users);die;
$email_check
=
$this
->
UserPersonals
->
find
(
'all'
,
[
'conditions'
=>
[
'UserPersonals.email'
=>
$this
->
request
->
data
[
'email'
]
]
])
->
toArray
();
if
((
empty
(
$username_check
))
&&
(
empty
(
$email_check
)))
{
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
// pr($users);die;
//------------------------------ ส่งอีเมล์ -----------------------------------------------------
//------------------------------ ส่งอีเมล์ -----------------------------------------------------
$data_notification
=
[];
$data_notification
=
[];
$data_notification
[
'email'
]
=
$this
->
request
->
data
[
'email'
];
$data_notification
[
'email'
]
=
$this
->
request
->
data
[
'email'
];
$data_notification
[
'pin_code'
]
=
$users
[
'pin_code'
];
$data_notification
[
'pin_code'
]
=
$users
[
'pin_code'
];
$this
->
notification
(
$data_notification
);
$this
->
notification
(
$data_notification
);
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
$this
->
Users
->
save
(
$users
);
$this
->
Users
->
save
(
$users
);
$user_personals
[
'master_country_id'
]
=
$master_country_id
;
$user_personals
[
'master_country_id'
]
=
$master_country_id
;
$user_personals
[
'master_province_id'
]
=
$master_province_id
;
$user_personals
[
'master_province_id'
]
=
$master_province_id
;
$user_personals
[
'user_id'
]
=
$users
[
'id'
];
$user_personals
[
'user_id'
]
=
$users
[
'id'
];
$user_personals
[
'firstname_th'
]
=
$firstname
;
$user_personals
[
'firstname_th'
]
=
$firstname
;
$user_personals
[
'lastname_th'
]
=
$lastname
;
$user_personals
[
'lastname_th'
]
=
$lastname
;
$user_personals
[
'created_by'
]
=
1
;
$user_personals
[
'created_by'
]
=
1
;
$user_personals
[
'created'
]
=
$dateNow
;
$user_personals
[
'created'
]
=
$dateNow
;
$user_personals
=
$this
->
UserPersonals
->
patchEntity
(
$user_personals
,
$this
->
request
->
getData
());
$user_personals
=
$this
->
UserPersonals
->
patchEntity
(
$user_personals
,
$this
->
request
->
getData
());
$this
->
UserPersonals
->
save
(
$user_personals
);
$this
->
UserPersonals
->
save
(
$user_personals
);
// $this->Flash->success(__('The register success.'));
// $this->Flash->success(__('The register success.'));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'pinCode/'
.
$users
[
'token'
]]);
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'pinCode/'
.
$users
[
'token'
]]);
// return $this->redirect(['action' => 'signin']);
// return $this->redirect(['action' => 'signin']);
}
}
$this
->
Flash
->
error
(
__
(
'Username or Email Address already used by others.'
));
$this
->
Flash
->
error
(
__
(
'Username or Email Address already used by others.'
));
return
$this
->
redirect
([
'action'
=>
'signup'
]);
return
$this
->
redirect
([
'action'
=>
'signup'
]);
}
else
if
(
empty
(
$this
->
request
->
data
[
'accept'
]))
{
}
else
if
(
empty
(
$this
->
request
->
data
[
'accept'
]))
{
$this
->
Flash
->
error
(
__
(
'please accept'
));
$this
->
Flash
->
error
(
__
(
'please accept'
));
return
$this
->
redirect
([
'action'
=>
'signup'
]);
return
$this
->
redirect
([
'action'
=>
'signup'
]);
}
}
$this
->
Flash
->
error
(
__
(
'The article could not be saved. Please, try again.'
));
$this
->
Flash
->
error
(
__
(
'The article could not be saved. Please, try again.'
));
}
}
}
public
function
notification
(
$data
=
null
)
{
if
(
!
empty
(
$data
)){
$verify_code
=
$data
[
'pin_code'
];
$from_email
=
[
'support@pakgon.com'
=>
'Support'
];
$to_emails
=
[
$data
[
'email'
]];
$email
=
new
Email
();
$email
->
transport
(
'gmail'
);
try
{
$email
->
template
(
'notification_signup'
,
'connect'
);
$email
->
from
(
$from_email
);
$email
->
to
(
$to_emails
);
$email
->
subject
(
'Signup Connect Verify'
);
$email
->
emailFormat
(
'html'
);
$email
->
viewVars
(
compact
(
'verify_code'
));
#$email->send($message);
$email
->
send
();
}
catch
(
Exception
$e
)
{
echo
'Exception : '
,
$e
->
getMessage
(),
"
\n
"
;
}
#$this->httpStatusCode = 200;
#$this->apiResponse['message'] = 'Signup Connect Completed!!';
}
}
}
public
function
notification
(
$data
=
null
)
{
if
(
!
empty
(
$data
))
{
$verify_code
=
$data
[
'pin_code'
];
$from_email
=
[
'support@pakgon.com'
=>
'Support'
];
$to_emails
=
[
$data
[
'email'
]];
$email
=
new
Email
();
$email
->
transport
(
'gmail'
);
try
{
$email
->
template
(
'notification_signup'
,
'connect'
);
$email
->
from
(
$from_email
);
$email
->
to
(
$to_emails
);
$email
->
subject
(
'Signup Connect Verify'
);
$email
->
emailFormat
(
'html'
);
$email
->
viewVars
(
compact
(
'verify_code'
));
#$email->send($message);
$email
->
send
();
}
catch
(
Exception
$e
)
{
echo
'Exception : '
,
$e
->
getMessage
(),
"
\n
"
;
}
#$this->httpStatusCode = 200;
#$this->apiResponse['message'] = 'Signup Connect Completed!!';
}
}
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
function
validateAccount
(
$data
=
null
)
{
function
validateAccount
(
$data
=
null
)
{
...
@@ -273,80 +277,76 @@ class UsersController extends AppController {
...
@@ -273,80 +277,76 @@ class UsersController extends AppController {
// }
// }
#Verify Pin Code
#Verify Pin Code
public
function
pinCode
(
$token
=
null
)
public
function
pinCode
(
$token
=
null
)
{
{
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$data
=
$this
->
request
->
data
();
$data
=
$this
->
request
->
data
();
if
(
!
empty
(
$data
)){
if
(
!
empty
(
$data
))
{
$api_core_verify_pin_code
=
Configure
::
read
(
'Config.apiCore.verifyPinCode'
);
$http
=
new
Client
();
#$response = json_decode($http->post($api_core_verify_pin_code,$data)->body(),'_full');
$response
=
$http
->
post
(
$api_core_verify_pin_code
,
$data
)
->
body
();
$response
=
json_decode
(
$response
,
'_full'
);
if
(
!
empty
(
$response
)){
if
(
trim
(
$response
[
'status'
])
==
'Success'
){
$this
->
Flash
->
success
(
__
(
'Verify Completed.'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'signin'
]);
}
else
{
$this
->
Flash
->
error
(
__
(
'Pin Code Invalid'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'pinCode/'
.
$token
]);
}
}
}
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
}
#---------------------------------------------------------------------------------------------------
$api_core_verify_pin_code
=
Configure
::
read
(
'Config.apiCore.verifyPinCode'
);
$http
=
new
Client
();
#$response = json_decode($http->post($api_core_verify_pin_code,$data)->body(),'_full');
$response
=
$http
->
post
(
$api_core_verify_pin_code
,
$data
)
->
body
();
$response
=
json_decode
(
$response
,
'_full'
);
if
(
!
empty
(
$response
))
{
if
(
trim
(
$response
[
'status'
])
==
'Success'
)
{
$this
->
Flash
->
success
(
__
(
'Verify Completed.'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'signin'
]);
}
else
{
$this
->
Flash
->
error
(
__
(
'Pin Code Invalid'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'pinCode/'
.
$token
]);
}
}
}
$this
->
set
(
array
(
'token'
=>
$token
,
'_serialize'
=>
array
(
'token'
)));
}
#---------------------------------------------------------------------------------------------------
/**
*
public
function
forgotPassword
()
* Function user forgot password
{
* @return void
$this
->
viewBuilder
()
->
layout
(
'blank'
);
*/
$this
->
loadModel
(
'UserPersonals'
);
public
function
forgotPassword
()
{
if
(
$this
->
request
->
is
(
'post'
))
{
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$hasher
=
new
DefaultPasswordHasher
();
$this
->
loadModel
(
'UserPersonals'
);
$email
=
$this
->
request
->
data
[
'email'
];
if
(
$this
->
request
->
is
(
'post'
))
{
$user_personals
=
$this
->
UserPersonals
->
find
(
'all'
,[
$hasher
=
new
DefaultPasswordHasher
();
'conditions'
=>
[
$email
=
$this
->
request
->
data
[
'email'
];
'UserPersonals.email'
=>
$email
$user_personals
=
$this
->
UserPersonals
->
find
(
'all'
,
[
]
'conditions'
=>
[
])
->
first
();
'UserPersonals.email'
=>
$email
if
(
!
empty
(
$user_personals
)){
]
])
->
first
();
$users
=
$this
->
Users
->
find
(
'all'
,[
if
(
!
empty
(
$user_personals
))
{
'conditions'
=>
[
'Users.id'
=>
$user_personals
[
'user_id'
]
$users
=
$this
->
Users
->
find
(
'all'
,
[
]
'conditions'
=>
[
])
->
first
();
'Users.id'
=>
$user_personals
[
'user_id'
]
$digits
=
4
;
]
$users
[
'pin_pass'
]
=
str_pad
(
rand
(
0
,
pow
(
10
,
$digits
)
-
1
),
$digits
,
'0'
,
STR_PAD_LEFT
);
])
->
first
();
$token
=
$users
[
'token'
];
$digits
=
4
;
$users
[
'pin_pass'
]
=
str_pad
(
rand
(
0
,
pow
(
10
,
$digits
)
-
1
),
$digits
,
'0'
,
STR_PAD_LEFT
);
//--------------------ตัวส่ง Email ---------------------------------------------------------
$token
=
$users
[
'token'
];
//pr($user_personals);die;
$data_notification
=
[];
//--------------------ตัวส่ง Email ---------------------------------------------------------
$data_notification
[
'email'
]
=
$this
->
request
->
data
[
'email'
];
//pr($user_personals);die;
$data_notification
[
'pin_code'
]
=
$users
[
'pin_pass'
]
.
'<br>'
.
" Username: "
.
$users
[
'username'
];
$data_notification
=
[];
$this
->
notification
(
$data_notification
);
$data_notification
[
'email'
]
=
$this
->
request
->
data
[
'email'
];
//----------------------------------------------------------------------------------------
$data_notification
[
'pin_code'
]
=
$users
[
'pin_pass'
];
$this
->
Users
->
save
(
$users
);
$this
->
notification
(
$data_notification
);
//----------------------------------------------------------------------------------------
$this
->
Flash
->
success
(
__
(
'send password to email success'
));
$this
->
Users
->
save
(
$users
);
return
$this
->
redirect
([
'action'
=>
'pinCodepassword/'
.
$token
]);
}
else
{
$this
->
Flash
->
success
(
__
(
'send password to email success'
));
$this
->
Flash
->
error
(
__
(
'Invalid Email.'
));
return
$this
->
redirect
([
'action'
=>
'pinCodepassword/'
.
$token
]);
return
$this
->
redirect
([
'action'
=>
'forgot-password'
]);
}
else
{
}
$this
->
Flash
->
error
(
__
(
'Invalid Email.'
));
return
$this
->
redirect
([
'action'
=>
'forgot-password'
]);
}
}
}
}
}
...
@@ -423,8 +423,75 @@ class UsersController extends AppController {
...
@@ -423,8 +423,75 @@ class UsersController extends AppController {
}
}
// if ($this->request->is('post')) {
// $data = $this->request->data();
// $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']) {
// $this->Flash->success(__('Pin Completed.'));
// return $this->redirect(['controller' => 'Users', 'action' => 'changeForgotpassword/' . $token]);
// }
// $this->Flash->error(__('Pin Invalid'));
// return $this->redirect(['controller' => 'Users', 'action' => 'pinCodepassword/' . $token]);
// }
// $this->set(array('token' => $token, '_serialize' => array('token')));
// }
// public function changePassword($token = null) {
// $id = $this->Auth->user('id');
// $this->viewBuilder()->layout('blank');
// $users = $this->Users->get($id);
// if ($this->request->is('post')) {
// $hasher = new DefaultPasswordHasher();
// $password = $this->request->data['password'];
// $confirm_password = $this->request->data['confirm_password'];
// $oldpassword = $this->request->data['oldpassword'];
// $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'));
// $this->Flash->success(__('You are now logged out.'));
// return $this->redirect(['action' => 'signout']);
// } else {
// $this->Flash->error(__('Invalid password.'));
// return $this->redirect(['action' => 'change-password']);
// }
// }
// $this->set(array('token' => $token, '_serialize' => array('token')));
// }
// public function changeForgotpassword($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());
// if ($this->Users->save($users)) {
// $this->Flash->success(__('change password success'));
// return $this->redirect(['action' => 'signin']);
// }
// $this->Flash->error(__('Invalid password.'));
// return $this->redirect(['action' => 'change_forgotpassword']);
// }
// $this->set(array('token' => $token, '_serialize' => array('token')));
// }
#---------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------
/**
/**
*
*
* Function user logout / signout
* Function user logout / signout
...
@@ -440,6 +507,7 @@ class UsersController extends AppController {
...
@@ -440,6 +507,7 @@ class UsersController extends AppController {
return
$this
->
redirect
(
$this
->
Auth
->
logout
());
return
$this
->
redirect
(
$this
->
Auth
->
logout
());
}
}
public
function
forgotsendpin
(
$token
=
null
)
{
public
function
forgotsendpin
(
$token
=
null
)
{
$this
->
loadModel
(
'UserPersonals'
);
$this
->
loadModel
(
'UserPersonals'
);
$users
=
$this
->
Users
->
find
(
'all'
,[
$users
=
$this
->
Users
->
find
(
'all'
,[
...
@@ -498,7 +566,6 @@ class UsersController extends AppController {
...
@@ -498,7 +566,6 @@ class UsersController extends AppController {
}
}
$this
->
Flash
->
success
(
__
(
'send pin false.'
));
$this
->
Flash
->
success
(
__
(
'send pin false.'
));
return
$this
->
redirect
([
'action'
=>
'pin_code/'
.
$token
]);
return
$this
->
redirect
([
'action'
=>
'pin_code/'
.
$token
]);
}
}
}
}
www/src/Template/Layout/blank.ctp
View file @
1f2c42df
...
@@ -17,40 +17,40 @@
...
@@ -17,40 +17,40 @@
<link
href=
"https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800%7CShadows+Into+Light"
rel=
"stylesheet"
type=
"text/css"
>
<link
href=
"https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800%7CShadows+Into+Light"
rel=
"stylesheet"
type=
"text/css"
>
<!-- Vendor CSS -->
<!-- Vendor CSS -->
<?php echo $this->Html->css('/css/pakgon.css'); ?>
<?php echo $this->Html->css('/css/pakgon.css'); ?>
<?php echo $this->Html->css('/css/bootstrap/css/bootstrap.min') ?>
<?php echo $this->Html->css('/css/bootstrap/css/bootstrap.min')
;
?>
<?php echo $this->Html->css('/css/font-awesome/css/font-awesome.min') ?>
<?php echo $this->Html->css('/css/font-awesome/css/font-awesome.min')
;
?>
<?php echo $this->Html->css('/css/animate/animate.min') ?>
<?php echo $this->Html->css('/css/animate/animate.min')
;
?>
<?php echo $this->Html->css('/css/simple-line-icons/css/simple-line-icons.min') ?>
<?php echo $this->Html->css('/css/simple-line-icons/css/simple-line-icons.min')
;
?>
<?php echo $this->Html->css('/css/owl.carousel/assets/owl.carousel.min') ?>
<?php echo $this->Html->css('/css/owl.carousel/assets/owl.carousel.min')
;
?>
<?php echo $this->Html->css('/css/owl.carousel/assets/owl.theme.default.min') ?>
<?php echo $this->Html->css('/css/owl.carousel/assets/owl.theme.default.min')
;
?>
<?php echo $this->Html->css('/css/magnific-popup/magnific-popup.min') ?>
<?php echo $this->Html->css('/css/magnific-popup/magnific-popup.min')
;
?>
<!-- Theme CSS -->
<!-- Theme CSS -->
<?php echo $this->Html->css('/css/css/theme') ?>
<?php echo $this->Html->css('/css/css/theme')
;
?>
<?php echo $this->Html->css('/css/css/theme-elements') ?>
<?php echo $this->Html->css('/css/css/theme-elements')
;
?>
<?php echo $this->Html->css('/css/css/theme-blog') ?>
<?php echo $this->Html->css('/css/css/theme-blog')
;
?>
<?php echo $this->Html->css('/css/css/theme-shop') ?>
<?php echo $this->Html->css('/css/css/theme-shop')
;
?>
<!-- Skin CSS -->
<!-- Skin CSS -->
<?php echo $this->Html->css('/css/css/skins/default') ?>
<?php echo $this->Html->css('/css/css/skins/default')
;
?>
<?php echo $this->Html->script('/js/master/style-switcher/style.switcher.localstorage'); ?>
<?php echo $this->Html->script('/js/master/style-switcher/style.switcher.localstorage'); ?>
<!-- Theme Custom CSS -->
<!-- Theme Custom CSS -->
<?php echo $this->Html->css('/css/css/custom') ?>
<?php echo $this->Html->css('/css/css/custom')
;
?>
<!-- Head Libs -->
<!-- Head Libs -->
<?php echo $this->Html->script('/js/modernizr/modernizr.min'); ?>
<?php echo $this->Html->script('/js/modernizr/modernizr.min'); ?>
<!-- APP -->
<!-- APP -->
<?php echo $this->Html->script('custom/core'); ?>
<?php echo $this->Html->script('custom/core'); ?>
<?php echo $this->Html->css('/css/pakgon.css'); ?>
<?php echo $this->Html->css('/css/pakgon.css'); ?>
<style>
<style
type=
"text/css"
>
@font-face
{
@font-face
{
font-family
:
'Conv_supermarket'
;
font-family
:
'Conv_supermarket'
;
src
:
url('..
/font/fonts/supermarket.eot')
;
src
:
url('
/font/fonts/supermarket.eot')
;
src
:
local
(
'☺'
),
url('../font/fonts/supermarket.woff')
format
(
'woff'
),
url('../font/fonts/supermarket.ttf')
format
(
'truetype'
),
url('..
/font/fonts/supermarket.svg')
format
(
'svg'
);
src
:
local
(
'☺'
),
url('/font/fonts/supermarket.woff')
format
(
'woff'
),
url('/font/fonts/supermarket.ttf')
format
(
'truetype'
),
url('
/font/fonts/supermarket.svg')
format
(
'svg'
);
font-weight
:
normal
;
font-weight
:
normal
;
font-style
:
normal
;
font-style
:
normal
;
}
}
</style>
</style>
<?php echo $this->Html->script('/js/jquery/jquery-1.11.3.min'); ?>
<?php echo $this->Html->script('/js/jquery/jquery-1.11.3.min'); ?>
<!-- Isolated Version of Bootstrap, not needed if your site already uses Bootstrap -->
<!-- Isolated Version of Bootstrap, not needed if your site already uses Bootstrap -->
<?php echo $this->Html->css('/css/css/bootstrap-iso') ?>
<?php echo $this->Html->css('/css/css/bootstrap-iso')
;
?>
<?php echo $this->Html->script('/js/jquery/alex-date-time'); ?>
<?php echo $this->Html->script('/js/jquery/alex-date-time'); ?>
<?php echo $this->Html->css('/css/chosen_v151/bootstrap-chosen/bootstrap-chosen.css'); ?>
<?php echo $this->Html->css('/css/chosen_v151/bootstrap-chosen/bootstrap-chosen.css'); ?>
<?php echo $this->Html->script('/css/chosen_v151/chosen.jquery.min.js'); //Chosen select box?>
<?php echo $this->Html->script('/css/chosen_v151/chosen.jquery.min.js'); //Chosen select box?>
...
@@ -76,6 +76,7 @@
...
@@ -76,6 +76,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
<?php echo $this->Html->script('/js/cleave-phone.th'); ?>
<?php echo $this->Html->script('/js/cleave-phone.th'); ?>
<?php echo $this->Html->script('/js/cleave.min'); ?>
<?php echo $this->Html->script('/js/cleave.min'); ?>
<?php echo $this->Html->script('jquery.appear/jquery.appear.min'); ?>
<?php echo $this->Html->script('jquery.appear/jquery.appear.min'); ?>
...
...
www/src/Template/Profiles/index.ctp
View file @
1f2c42df
...
@@ -17,11 +17,11 @@
...
@@ -17,11 +17,11 @@
$this->marginInRows=($marginInRows>0 && $marginInRows<10) ? $marginInRows:4;
$this->marginInRows=($marginInRows>0 && $marginInRows<10) ? $marginInRows:4;
$this->debug = ($debug==true)? true:false;
$this->debug = ($debug==true)? true:false;
}
}
public function generate(){
public function generate(){
$QRLink = "https://chart.googleapis.com/chart?cht=qr&chs=".$this->size."x".$this->size. "&chl=" . $this->data .
$QRLink = "https://chart.googleapis.com/chart?cht=qr&chs=".$this->size."x".$this->size. "&chl=" . $this->data .
"&choe=" . $this->encoding .
"&choe=" . $this->encoding .
"&chld=" . $this->errorCorrectionLevel . "|" . $this->marginInRows;
"&chld=" . $this->errorCorrectionLevel . "|" . $this->marginInRows;
if ($this->debug) echo $QRLink;
if ($this->debug) echo $QRLink;
return $QRLink;
return $QRLink;
}
}
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
<div class="row">
<div class="row">
<div class="col-xs-1 col-sm-1 col-md-1 box-arrow" ></div>
<div class="col-xs-1 col-sm-1 col-md-1 box-arrow" ></div>
<div class="col-xs-10 col-sm-10 col-md-10">
<div class="col-xs-10 col-sm-10 col-md-10">
<div data-toggle="modal" data-target="#defaultModal" style="text-align: center; cursor: pointer;">
<div data-toggle="modal" data-target="#defaultModal" style="text-align: center; cursor: pointer;">
<img src="/img/core/img/connect-card-v3.png" class="img-responsive" id="img-upload" alt="Profile picture">
<img src="/img/core/img/connect-card-v3.png" class="img-responsive" id="img-upload" alt="Profile picture">
...
@@ -193,7 +192,7 @@
...
@@ -193,7 +192,7 @@
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="modal fade" id="defaultModal" tabindex="-1" role="dialog" aria-labelledby="defaultModalLabel" aria-hidden="true">
<div class="modal fade" id="defaultModal" tabindex="-1" role="dialog" aria-labelledby="defaultModalLabel" aria-hidden="true">
<div class="modal-dialog box-ads">
<div class="modal-dialog box-ads">
<a class="close-modal" data-dismiss="modal">X </a>
<a class="close-modal" data-dismiss="modal">X </a>
<div class="container login-container">
<div class="container login-container">
<div class="owl-carousel owl-theme" data-plugin-options="{'items': 1}">
<div class="owl-carousel owl-theme" data-plugin-options="{'items': 1}">
<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