Skip to content

Commit e80cc02

Browse files
committed
定制 http header
1 parent 0f9961d commit e80cc02

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

application/controllers/Login.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public function Login() {
5555
);
5656
// set cookie + set session
5757
$this->input->set_cookie($cookie);
58-
if ($_SESSION['nonces']==$post['nonces']) {
58+
if ($_SESSION['nonces']==$post['nonces'] && $this->input->get_request_header('login-custom-header', TRUE)=='login-csrf') {
5959
// VALID TOKEN PROVIDED - PROCEED WITH PROCESS
6060
$response = array('status'=>'2','msg'=>'success','data'=>$user['data']);
6161
echo json_encode($response);
6262
} else {
63-
$response = array('status'=>'0','msg'=>'failed','data'=>'nonces error');
63+
$response = array('status'=>'0','msg'=>'failed','data'=>'nonces error or login-custom-header error');
6464
echo json_encode($response);
6565
}
6666
}else {

application/views/login.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
type: "post",
4848
data: values,
4949
url: "./Login/Login",
50+
headers: { 'login-custom-header': 'login-csrf' },
5051
dataType: 'json',
5152
success: function(data) {
5253
if(data.status == 2){

0 commit comments

Comments
 (0)