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
f31c1fb2
authored
May 24, 2018
by
Teeradone-PIM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teeradone validate register
parent
2faaee2b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
31 deletions
+53
-31
www/src/Controller/UsersController.php
+11
-25
www/src/Template/Users/change_forgotpassword.ctp
+1
-1
www/src/Template/Users/signup.ctp
+41
-5
No files found.
www/src/Controller/UsersController.php
View file @
f31c1fb2
...
...
@@ -18,7 +18,7 @@ class UsersController extends AppController {
*/
public
function
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
()
{
...
...
@@ -315,25 +315,6 @@ class UsersController extends AppController {
if
(
$this
->
request
->
is
(
'post'
))
{
$hasher
=
new
DefaultPasswordHasher
();
$email
=
$this
->
request
->
data
[
'email'
];
//-------------------RandomPassword---------------------------------------------------------
// $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
// $pass = array();
// $alphaLength = strlen($alphabet) - 1;
// for ($i = 0; $i < 8; $i++) {
// $n = rand(0, $alphaLength);
// $pass[] = $alphabet[$n];
// }
// $password = implode($pass);
//--------------------ตัวส่ง Email --------------------------------------
//pr($user_personals);die;
// $data_notification = [];
// $data_notification['email'] = $this->request->data['email'];
// $data_notification['password'] = $password;
// $this->notification($data_notification);
//------------------------------------------------------------------------------------------
$user_personals
=
$this
->
UserPersonals
->
find
(
'all'
,[
'conditions'
=>
[
'UserPersonals.email'
=>
$email
...
...
@@ -382,7 +363,7 @@ class UsersController extends AppController {
$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'
=>
'change
P
assword/'
.
$token
]);
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'change
Forgotp
assword/'
.
$token
]);
}
$this
->
Flash
->
error
(
__
(
'Pin Invalid'
));
return
$this
->
redirect
([
'controller'
=>
'Users'
,
'action'
=>
'pinCodepassword/'
.
$token
]);
...
...
@@ -395,10 +376,12 @@ class UsersController extends AppController {
$this
->
viewBuilder
()
->
layout
(
'blank'
);
$users
=
$this
->
Users
->
find
(
'all'
,[
'conditions'
=>
[
'Users.
token'
=>
$token
'Users.
id'
=>
$this
->
Auth
->
user
(
'id'
)
]
])
->
first
();
if
(
$this
->
request
->
is
(
'post'
))
{
$oldpassword
=
$this
->
request
->
data
[
'oldpassword'
];
// pr($this->request->data['oldpassword']);die;
$hasher
=
new
DefaultPasswordHasher
();
$password
=
$this
->
request
->
data
[
'password'
];
$confirm_password
=
$this
->
request
->
data
[
'confirm_password'
];
...
...
@@ -408,7 +391,7 @@ class UsersController extends AppController {
$users
=
$this
->
Users
->
patchEntity
(
$users
,
$this
->
request
->
getData
());
$this
->
Users
->
save
(
$users
);
$this
->
Flash
->
success
(
__
(
'change password success'
));
return
$this
->
redirect
([
'action'
=>
'sign
in
'
]);
return
$this
->
redirect
([
'action'
=>
'sign
out
'
]);
}
else
{
$this
->
Flash
->
error
(
__
(
'Invalid password.'
));
return
$this
->
redirect
([
'action'
=>
'change-password/'
.
$token
]);
...
...
@@ -417,7 +400,7 @@ class UsersController extends AppController {
$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'
);
$users
=
$this
->
Users
->
find
(
'all'
,[
...
...
@@ -432,10 +415,13 @@ class UsersController extends AppController {
$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
);
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'
)));
}
...
...
www/src/Template/Users/change_forgotpassword.ctp
View file @
f31c1fb2
...
...
@@ -6,7 +6,7 @@
<!-- <div class="alert alert-warning" role="alert" style="margin: 10px 0px 10px 0px;font-size: 17px;text-align: center;">
<strong><?php echo __('กรุณา! ตรวจสอบอีเมลล์ของท่าน');?></strong>
</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(); ?>
</div>
<div>
...
...
www/src/Template/Users/signup.ctp
View file @
f31c1fb2
...
...
@@ -29,7 +29,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ชื่อผู้ใช้งาน');?><em>* </em></label>
<input type="text" name="username" id="username" value="" onkeypress="check
_notnum
();" placeholder="USERNAME" class="form-control-reg border-bottom-from">
<input type="text" name="username" id="username" value="" onkeypress="check
eng
();" placeholder="USERNAME" class="form-control-reg border-bottom-from">
</div>
</div>
...
...
@@ -109,7 +109,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('รหัสผ่าน');?><em>* </em></label>
<input data-toggle="password" data-placement="before" type="password" name="password" id="password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from" style="padding:0px 0px !important;">
<input data-toggle="password" data-placement="before"
onkeypress="checkeng();"
type="password" name="password" id="password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from" style="padding:0px 0px !important;">
<!--<input type="password" name="data[password]" id="password" value="" placeholder="********" class="form-control-reg border-bottom-from" onkeyup='check();'>-->
<!--<span class="glyphicon glyphicon-eye-close form-control-feedback"></span>-->
</div>
...
...
@@ -119,7 +119,7 @@
<div class="form-group has-feedback">
<div class="col-md-12">
<label class="label-text-sub"><?php echo __('ยืนยันรหัสผ่าน');?><em>* </em></label>
<input data-toggle="password" data-placement="before" type="password" name="confirm_password" id="confirm_password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from" style="padding:0px 0px !important;">
<input data-toggle="password" data-placement="before"
onkeypress="checkeng();"
type="password" name="confirm_password" id="confirm_password" value="" placeholder="********" class="form-control input-lg color-button-border border-bottom-from" style="padding:0px 0px !important;">
<!--<input type="password" id="confirm_password" name="data[confirm_password]" value="" placeholder="********" class="form-control-reg border-bottom-from" onkeyup='check();'>-->
<!--<span class="glyphicon glyphicon-eye-close form-control-feedback" id='message'></span>-->
<span id='message'></span>
...
...
@@ -176,8 +176,34 @@
});
</script>
<script>
// function check_key() {
// e_k=event.keyCode
// alert( 'asdasd')
// if ((k>=65 && k<=90) || (k>=97 && k<=122)){
// return true;
// }else{
// alert("thai");
// return false;
// }
// }
$(document).ready(function() {
// $("#username").on('keyup',function(){
// var $this = $(this);
// if($this.val().length>=4){
// alert(check_key());
// }else{
// //alert("กรุณากรอกชื่อผู้ใช้งานของท่าน");
// // return false;
// }
// });
$("#fremail").on('change',function(){
var email = document.getElementById("fremail").value;
$.post("/Checkemails/checkemail", {email: email}, function(data) {
...
...
@@ -205,6 +231,16 @@
alert("ข้อมูลผิดพลาด กรุณาใส่ข้อมูลที่เป็นตัวอักษรภาษาไทย [ก-ฮ] หรือภาษาอังกฤษให้ถูกต้อง");
}
}
function checkeng()
{
e_k=event.keyCode
if ((e_k >= 48 && e_k<=57) || (e_k>=97 && e_k<=122) || ((e_k>=65 && e_k<=90))) {
e_k = true;
}else{
e_k = false;
alert("กรุณากรอกชือผู้ใช้เป็นเป็นตัวอักษรภาษาอังกฤษตัวเล็กหรือตัวใหญ่และมีหรือไม่มีตัวเลขผสมอยู่");
}
}
function validateForm() {
var firstname = document.getElementById("firstname").value;
...
...
@@ -222,9 +258,9 @@
alert("กรุณากรอกชื่อผู้ใช้งานของท่าน");
return false;
}
if(document.getElementById("username").value.length <
5
)
if(document.getElementById("username").value.length <
4 || document.getElementById("username").value.length > 10
)
{
alert('กรุณาระบุชื่อผู้ใช้งาน
อย่างน้อย 5
ตัวอักษร');
alert('กรุณาระบุชื่อผู้ใช้งาน
ความยาว 4-10
ตัวอักษร');
return false;
}
var master_country_id = document.getElementById("master_country_id").value;
...
...
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