From 8ed2e27ad968090d408a9793c76593bd54118fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=AD=90=E7=90=A6?= Date: Sat, 23 Mar 2019 21:08:09 +0800 Subject: [PATCH 1/8] addpassword --- application/.DS_Store | Bin 0 -> 10244 bytes application/libraries/MY_Email.php | 14 +++++- application/views/login_form.php | 4 ++ application/views/resetpw_form.php | 60 ++++++++++++++++++++++++++ application/views/resetpw_success.php | 20 +++++++++ signup_success 2.php | 20 +++++++++ signup_success.php | 20 +++++++++ 7 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 application/.DS_Store create mode 100644 application/views/resetpw_form.php create mode 100644 application/views/resetpw_success.php create mode 100644 signup_success 2.php create mode 100644 signup_success.php diff --git a/application/.DS_Store b/application/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2e25edb02c5f83ec23cd704bc0f1cc4baebc8c9e GIT binary patch literal 10244 zcmeHMOK=oL82 z{Xe?r|N5KR?Op)DSVoTkgaJUJi%GSPs@oK1XV;ukSt0qWgDSoSAX!6d zUZ_p`03H+eWz?6mLh?`=Q|unl4@G~Afg+sjVdhRU>dRRnML3`c2lQt~e}{s6c8Uvg zcfhESK^-6vATSpJws)_E6gXhR@rwQXSIH^MbiJ0A8(39cGp}~OBukRCP&zU&;p7Iq zgqLw+iS%LC>rZ$SNxwblI99QpNFFqeTwGn+cXBZ&W9u#- zXFwQaNtWffs^#;M&erDemd=iu=5W5fy`?$a*1BzGMwV7IM!NcrO-`T6KQ;68d65_T z?*?E=m6i+CDN9m!Q&y60lR1?cvIA+`a_n)^v%wbl$as(@ge>|P)N)JCIQ}SLbhC(& zBG<`_A(uG&wdi&y~tJioC6ydBF{bKzoweEmS0ocC*uL5G3Ks6yr zuqNm-31GK$kQy>OFn&wP?xGeZNvV^sb;}^8^k9MpNs}=SQ+!AdrV9hI*m;oUv*gN_ z@r%MTmQY>3TU2MOvpkQA9efFMwXuD;gn-#CT%ya)~6Cy zDq|6YyDf`3yCa@)(qpYdu9Nn9xMN&ZGp=#KAU`u}^pZD)E@30>pYlw{b`Kh9mt;e< zg(XFNyP`xM`$^a_k`*O}Ht;)=hhSIBU9Q z(lQ3^#H3MQ?a4BaTE0TlMlwnB$&Beus|}LGwX0TZ%9u`fvCq-jXuA5LB>cmxHSI97 z^rQ`{bwA+#Mok%XDJM1IJ3jEBq70s(mzV1LQ*GL;XhT*aX;`W*i+Nhx6m2*wQd1xE zl^vamHj;8CCn*)T9-Do2*G^44%4Xi1aJ~IghD~?%r9XX)?rN0Tx^Aa0br8Id~H;!$9+4!R@#UyD^46xEBxLAP(U{jN>?(_ynFn4`*-|pTX1kB3{7P z@O69xFX4N51>eUH@Dsd->>WX+s=(AoMZZwvXVfaEqkO2kxkp0IW(+hyXi zS|hAo$}Wj0tJVr@OzD-`Q>8*B_wLBNci;+KCDwfpKfq7KxZjCwKulYN8fV&iY`{j` zL~M)T7Hq>V+=)?Q9OK(Qd>s366c6DT9wF9E5bI8$g*N8!B%Z=NvF}-Y4xh&t@C=^C zb9mlo;YGYG7*^z6Ux9H#;=AR%tN1c1cMf_10s#U60s#U60{0>U)gq}dJOAH(=l}oj z#ngkG0t5mCd<3wjcc3>$ox*0V5*c>Z9;WLUU92#_Ss{4{Rs1-fBtMR)4m*zLyHwKo hyLuiMB|VFu6_Q$1?)skr!Tvwk|Np}yse5hz{}*+gE=B+V literal 0 HcmV?d00001 diff --git a/application/libraries/MY_Email.php b/application/libraries/MY_Email.php index 6e6da1d..9a950ba 100644 --- a/application/libraries/MY_Email.php +++ b/application/libraries/MY_Email.php @@ -59,7 +59,7 @@ public function send_mail( * Send account confirmation email. */ public function send_account_confirm_mail($mail) { - $subject = '第十六届全国高校自行车交流赛帐户确认(含ID)'; + $subject = '第十七届全国高校自行车交流赛帐户确认(含ID)'; $token = $this->ci->user->get_token($mail); $link = site_url('user/activate') . '/' . $token; $id = $this->ci->user->get_id($mail); @@ -67,12 +67,22 @@ public function send_account_confirm_mail($mail) { $message = '请点击以下链接激活帐户' . $link . $id_message; $this->send_mail($mail, $subject, $message); } +public function send_resetpw_confirm_mail($mail) { + $subject = '第十七届全国高校自行车交流赛帐户修改密码'; + $token = $this->ci->user->get_token($mail); + $link = site_url('user/activate') . '/' . $token; + $id = $this->ci->user->get_id($mail); + $id_message='

贵高校本次比赛的ID是' . $id . ',请领队同学务必牢记,并在比赛签到时出示。

祝好!

北京大学自行车协会'; + $message = '请点击以下链接激活帐户' . $link . $id_message; + $this->send_mail($mail, $subject, $message); + } + /* * Send mail after money is received. */ public function send_fee_received_mail($mail, $school, $fee) { - $subject = '第十六届全国高校自行车交流赛缴费确认'; + $subject = '第十七届全国高校自行车交流赛缴费确认'; $id = $this->ci->user->get_id($mail); $id_message='

贵高校本次比赛的ID是' . $id . ',请领队同学务必牢记,并在比赛签到时出示。

祝好!

北京大学自行车协会'; $message = $school . ',

贵校车协交来的' . $fee . '元参赛费用已经收到,感谢你们对北大赛的大力支持!如有任何问题,请直接与各地区负责联系。' . $id_message; diff --git a/application/views/login_form.php b/application/views/login_form.php index 8308a89..48ff34b 100644 --- a/application/views/login_form.php +++ b/application/views/login_form.php @@ -18,6 +18,10 @@

+
+ +
+

diff --git a/application/views/resetpw_form.php b/application/views/resetpw_form.php new file mode 100644 index 0000000..9ecc84e --- /dev/null +++ b/application/views/resetpw_form.php @@ -0,0 +1,60 @@ + +
+

重置密码

+
+ +
+ +


+ +
+ +


+ +
+ +


+ +
+ +


+
+
+ +
+
+ +
+
+ diff --git a/application/views/resetpw_success.php b/application/views/resetpw_success.php new file mode 100644 index 0000000..5ec0f09 --- /dev/null +++ b/application/views/resetpw_success.php @@ -0,0 +1,20 @@ + + + + + +修改密码成功 + + + +

修改密码成功,请登录您的邮箱查收激活邮件来激活您的帐户!

+ + + \ No newline at end of file diff --git a/signup_success 2.php b/signup_success 2.php new file mode 100644 index 0000000..5aa6763 --- /dev/null +++ b/signup_success 2.php @@ -0,0 +1,20 @@ + + + + + +注册成功 + + + +

注册成功,请登录您的邮箱查收激活邮件来激活您的帐户!
激活后管理员将于 24 小时内审核您的帐号,审核通过后即可登录!

+ + + \ No newline at end of file diff --git a/signup_success.php b/signup_success.php new file mode 100644 index 0000000..5aa6763 --- /dev/null +++ b/signup_success.php @@ -0,0 +1,20 @@ + + + + + +注册成功 + + + +

注册成功,请登录您的邮箱查收激活邮件来激活您的帐户!
激活后管理员将于 24 小时内审核您的帐号,审核通过后即可登录!

+ + + \ No newline at end of file From f0793a532d8741297d3de4087876e17bfb8e952f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=AD=90=E7=90=A6?= Date: Mon, 25 Mar 2019 13:56:31 +0800 Subject: [PATCH 2/8] addpassword backup 2019-3-25 --- application/controllers/user.php | 29 ++++++++++++++++++- application/libraries/MY_Email.php | 4 +-- application/views/forgetpw_form.php | 40 ++++++++++++++++++++++++++ application/views/forgetpw_success.php | 20 +++++++++++++ application/views/login_form.php | 4 +-- 5 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 application/views/forgetpw_form.php create mode 100644 application/views/forgetpw_success.php diff --git a/application/controllers/user.php b/application/controllers/user.php index d94ecfa..dd8d4e2 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -110,7 +110,34 @@ public function signup() { exit(err_msg($err_code)); } } - + public function forgetpw(){ + date_default_timezone_set('PRC'); + + if ($this->input->server('REQUEST_METHOD') == 'GET') { + $this->load->view('header_homepage'); + $this->load->view('add_hilight_nav2'); + $this->load->view('forgetpw_form'); + $this->load->view('footer'); + } + + if ($this->input->server('REQUEST_METHOD') == 'POST') { + $data = $this->input->post(); + header('Content-Type: application/json'); + + if ($this->form_validation->run('forgetpw') == false) { + $err_code = '402'; + } else { + $err_code = '200'; + $vcode_add = $data['vcode']; + $vcode = $this->user->get_vcode($data['mail']); + if ($vcode != $vcode_add) + $err_code = '403'; + else + $this->user->set_vcode($data['mail'],1); + } + exit(err_msg($err_code)); + } + } /* * Show registration result for the user. */ diff --git a/application/libraries/MY_Email.php b/application/libraries/MY_Email.php index 9a950ba..0aca524 100644 --- a/application/libraries/MY_Email.php +++ b/application/libraries/MY_Email.php @@ -72,8 +72,8 @@ public function send_resetpw_confirm_mail($mail) { $token = $this->ci->user->get_token($mail); $link = site_url('user/activate') . '/' . $token; $id = $this->ci->user->get_id($mail); - $id_message='

贵高校本次比赛的ID是' . $id . ',请领队同学务必牢记,并在比赛签到时出示。

祝好!

北京大学自行车协会'; - $message = '请点击以下链接激活帐户' . $link . $id_message; + $id_message='

贵高校本次比赛的ID是' . $id . '

祝好!

北京大学自行车协会'; + $message = '请点击以下链接重置帐户密码' . $link . $id_message; $this->send_mail($mail, $subject, $message); } diff --git a/application/views/forgetpw_form.php b/application/views/forgetpw_form.php new file mode 100644 index 0000000..a3f3c09 --- /dev/null +++ b/application/views/forgetpw_form.php @@ -0,0 +1,40 @@ + +
+

请输入注册邮箱

+

+ +
+ +


+
+
+ +
+
+ +
+
+ diff --git a/application/views/forgetpw_success.php b/application/views/forgetpw_success.php new file mode 100644 index 0000000..5ec0f09 --- /dev/null +++ b/application/views/forgetpw_success.php @@ -0,0 +1,20 @@ + + + + + +修改密码成功 + + + +

修改密码成功,请登录您的邮箱查收激活邮件来激活您的帐户!

+ + + \ No newline at end of file diff --git a/application/views/login_form.php b/application/views/login_form.php index 48ff34b..e8b71f2 100644 --- a/application/views/login_form.php +++ b/application/views/login_form.php @@ -18,9 +18,7 @@


-
- -
+

From 47d975f54d45520c3755211026ead26eac150c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=AD=90=E7=90=A6?= Date: Tue, 26 Mar 2019 16:48:40 +0800 Subject: [PATCH 3/8] addpassword backuo 2019-3-26 --- application/.DS_Store | Bin 10244 -> 10244 bytes application/config/constants.php | 3 + application/config/form_validation.php | 19 +++++ application/controllers/user.php | 73 ++++++++++++------ application/libraries/MY_Email.php | 5 +- application/models/user_model.php | 14 ++++ application/views/forgetpw_form.php | 6 +- application/views/resetpw_activate_footer.php | 2 + application/views/resetpw_activate_info.php | 1 + application/views/resetpw_form.php | 22 ++---- application/views/resetpw_header.php | 11 +++ assets/js/.Rhistory | 0 assets/js/race.js | 65 ++++++++++++++++ signup_success 2.php | 20 ----- signup_success.php | 20 ----- 15 files changed, 177 insertions(+), 84 deletions(-) create mode 100644 application/views/resetpw_activate_footer.php create mode 100644 application/views/resetpw_activate_info.php create mode 100644 application/views/resetpw_header.php create mode 100644 assets/js/.Rhistory delete mode 100644 signup_success 2.php delete mode 100644 signup_success.php diff --git a/application/.DS_Store b/application/.DS_Store index 2e25edb02c5f83ec23cd704bc0f1cc4baebc8c9e..71aff0d174eec17e29ab04ac46caae2506c7abe7 100644 GIT binary patch literal 10244 zcmeHMTWl0n82BoQ_G;)4&qXw(Ov^gnZEm))fpBm~9GZ07uD z{>!<1=bL}`oCN^vOsQdjAOHw-Gbxu-G0(;9?7r$M@-zXGNbvwVjK!zy$+%&~uk!X4 zJ_0@hJ_0@hJ_0@h{{;l-JDXiX8JB+PBj6+8BalUa<%b~MOh!F9$EBM(sBpIcB#TMy zUR0-jfEyF^WYm*$T)LsuCf_}v7mD5%19>>vgUp>|)RS{u@^C;N4(Roa-VO!b-YG8V zx&ubJ^h+NBAAze8V0-scNPq<<94Oeoe;S`OblYic{0fT}6ql4P6h!(g5*`^Cx26Uh z#Yx$nN^&oI+Mzh(aj!mTSw^<5#CPf1R7_slWtonmn_AKh)>VyMMu&A%wWd0)l&RWo zI|JOn`VnLD@|l@POH(KqiL}p#f-`MxjiF$3Q|s)kC{(Qt-`BT)V*1F;qqC2_%;$w( zZh(q{d7dnsq-rOOI1Q8e<;^}lkTea;93wqztjt5kfg~Yh&_|=1opZ+Vdj_M+S&SsH zTwE-c=c5#pYrMG)>#8$8sF^*6me$Pv!OJ$O#&bbW_y^x47U`5 zDOA_@?%bC;dgA1%v#-DL<_90TQIN&6l0Rq5kEnJHXfnwD4SEF_7rPiILCb`)Zc1IC z8R!Ieu3;gJlgWTdz7n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s366c6DT9wF9E5bI8$g*N8!B%Z=NvF}-Y4xh&t@C=^C zb9mlo;YGYG7*^z6Ux9H#;=AR%tN1c1cMf_10s#U60s#U60{0>U)gq}dJOAH(=l}oj z#ngkG0t5mCd<3wjcc3>$ox*0V5*c>Z9;WLUU92#_Ss{4{Rs1-fBtMR)4m*zLyHwKo hyLuiMB|VFu6_Q$1?)skr!Tvwk|Np}yse5hz{}*+gE=B+V diff --git a/application/config/constants.php b/application/config/constants.php index f6ae211..ccd86d6 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -74,10 +74,13 @@ '200' => 'OK.', '201' => '用户尚未激活,请您前往注册邮箱查收激活邮件!', '202' => '用户尚未通过审核,请您稍后登录!', + '203' => '用户未通过重置密码验证,请重新验证!', '204' => '用户不存在,请注册!', '205' => '注册已截止', + '206' => '两次密码不一致,请重新输入!', '400' => '存在不合法输入,请检查手机号、邮箱等信息是否正确填写!', '401' => '密码错误,请重新输入!', + '402' => '邮箱有误,请重新输入!', // Individual Registration Error. '999' => '人员名单不能为空。', '1000' => '第{order}个人的姓名不合法。', diff --git a/application/config/form_validation.php b/application/config/form_validation.php index 8975529..c70e162 100644 --- a/application/config/form_validation.php +++ b/application/config/form_validation.php @@ -59,6 +59,25 @@ 'label' => '密码', 'rules' => 'required|md5' ) + ), + 'forgetpw' => array( + array( + 'field' => 'mail', + 'label' => '电子邮箱', + 'rules' => 'trim|required|valid_email|xss_clean' + ) + ), + 'resetpw' => array( + array( + 'field' => 'password', + 'label' => '密码', + 'rules' => 'required|matches[passconf]|md5' + ), + array( + 'field' => 'passconf', + 'label' => '再次输入密码', + 'rules' => 'required|md5' + ) ) ); diff --git a/application/controllers/user.php b/application/controllers/user.php index dd8d4e2..497f65c 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -110,34 +110,43 @@ public function signup() { exit(err_msg($err_code)); } } - public function forgetpw(){ - date_default_timezone_set('PRC'); - - if ($this->input->server('REQUEST_METHOD') == 'GET') { - $this->load->view('header_homepage'); - $this->load->view('add_hilight_nav2'); - $this->load->view('forgetpw_form'); - $this->load->view('footer'); + public function forgetpw() { + + if ($this->input->server('REQUEST_METHOD') == 'GET') { + if ($this->session->userdata('logged_in')) { + redirect(base_url(), 'refresh'); } - - if ($this->input->server('REQUEST_METHOD') == 'POST') { - $data = $this->input->post(); - header('Content-Type: application/json'); - - if ($this->form_validation->run('forgetpw') == false) { - $err_code = '402'; - } else { - $err_code = '200'; - $vcode_add = $data['vcode']; - $vcode = $this->user->get_vcode($data['mail']); - if ($vcode != $vcode_add) - $err_code = '403'; - else - $this->user->set_vcode($data['mail'],1); - } + $this->load->view('header_homepage'); + $this->load->view('add_hilight_nav2'); + $this->load->view('forgetpw_form'); + $this->load->view('footer'); + } + + if ($this->input->server('REQUEST_METHOD') == 'POST') { + $login_info = $this->input->post(); + + header('Content-Type: application/json'); + if ($this->form_validation->run('forgetpw') == false) { + $err_code = '400'; exit(err_msg($err_code)); } + $user_info = $this->user->get_user_by_email($login_info['mail']); + if ($user_info == NULL) { + $err_code = '204'; + } elseif (!$user_info['activated']) { + $err_code = '201'; + } elseif (!$user_info['confirmed']) { + $err_code = '202'; + } else { + $err_code = '200'; + unset($data['passconf']); + $token = $this->user->generate_token($data['mail']); + $data = array_merge($data, array('token' => $token)); + $this->email->send_account_confirm_mail($data['mail']); + } + exit(err_msg($err_code)); } + } /* * Show registration result for the user. */ @@ -224,6 +233,22 @@ public function activate() { $this->load->view('activate_footer'); } +public function resetpw_activate() { + $this->load->model('user_model', 'user'); + $token = $this->uri->segment(3); + $this->load->view('resetpw_activate_header'); + $status = $this->user->resetpw_activate($token); + $data = array('info' => ''); + if ($status == 0) + $data['info'] = '重置密码激活成功!'; + elseif ($status == 1) + $data['info'] = '激活码无效或您已成功激活。'; + elseif ($status == 2) + $data['info'] = '激活码不存在。'; + $this->load->view('resetpw_activate_info', $data); + $this->load->view('resetpw_activate_footer'); + } + /* * Export an Excel file containing all the information. */ diff --git a/application/libraries/MY_Email.php b/application/libraries/MY_Email.php index 0aca524..3a043c2 100644 --- a/application/libraries/MY_Email.php +++ b/application/libraries/MY_Email.php @@ -67,10 +67,11 @@ public function send_account_confirm_mail($mail) { $message = '请点击以下链接激活帐户' . $link . $id_message; $this->send_mail($mail, $subject, $message); } -public function send_resetpw_confirm_mail($mail) { + + public function send_resetpw_confirm_mail($mail) { $subject = '第十七届全国高校自行车交流赛帐户修改密码'; $token = $this->ci->user->get_token($mail); - $link = site_url('user/activate') . '/' . $token; + $link = site_url('user/resetpw_activate') . '/' . $token; $id = $this->ci->user->get_id($mail); $id_message='

贵高校本次比赛的ID是' . $id . '

祝好!

北京大学自行车协会'; $message = '请点击以下链接重置帐户密码' . $link . $id_message; diff --git a/application/models/user_model.php b/application/models/user_model.php index d3a5bcb..2700494 100644 --- a/application/models/user_model.php +++ b/application/models/user_model.php @@ -243,6 +243,20 @@ public function activate($token) { } } +public function resetpw_activate($token) { + if (!$token) { + return 2; + } else { + $query = $this->db->where('token', $token)->get('users'); + if ($query->num_rows() == 0) { + return 1; + } else { + $this->db->where('token', $token)->update('users', array('token' => '0')); + return 0; + } + } + } + /* * This function freezes a certain user. */ diff --git a/application/views/forgetpw_form.php b/application/views/forgetpw_form.php index a3f3c09..13fa29e 100644 --- a/application/views/forgetpw_form.php +++ b/application/views/forgetpw_form.php @@ -1,5 +1,5 @@
@@ -22,7 +22,7 @@ if(event.keyCode == "13") { $("#btn-forgetpw").disabled=true; $("#btn-forgetpw").text("发送中..."); - postResetpw(); + forgetpw(); $("#btn-forgetpw").disabled=false; $("#btn-forgetpw").text("发送验证码"); } @@ -33,7 +33,7 @@ $("#btn-forgetpw").click(function() { this.disabled=true; $(this).text("发送中..."); - postSignup(); + forgetpw(); this.disabled=false; $(this).text("发送验证码"); }); diff --git a/application/views/resetpw_activate_footer.php b/application/views/resetpw_activate_footer.php new file mode 100644 index 0000000..691287b --- /dev/null +++ b/application/views/resetpw_activate_footer.php @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/application/views/resetpw_activate_info.php b/application/views/resetpw_activate_info.php new file mode 100644 index 0000000..8e0fba7 --- /dev/null +++ b/application/views/resetpw_activate_info.php @@ -0,0 +1 @@ +

\ No newline at end of file diff --git a/application/views/resetpw_form.php b/application/views/resetpw_form.php index 9ecc84e..b327d02 100644 --- a/application/views/resetpw_form.php +++ b/application/views/resetpw_form.php @@ -1,18 +1,10 @@

重置密码


- -
- -


- -
- -


@@ -33,10 +25,10 @@ $("#passconf").bind("keypress",function(event) { if(event.keyCode == "13") { $("#btn-signup").disabled=true; - $("#btn-signup").text("注册中..."); - postSignup(); + $("#btn-signup").text("重置中..."); + resetpw(); $("#btn-signup").disabled=false; - $("#btn-signup").text("注册"); + $("#btn-signup").text("重置"); } }); $("#btn-back").click(function() { @@ -44,10 +36,10 @@ }); $("#btn-signup").click(function() { this.disabled=true; - $(this).text("注册中..."); - postSignup(); + $(this).text("重置中..."); + resetpw(); this.disabled=false; - $(this).text("注册"); + $(this).text("重置"); }); $(document).ready(function() { var signUpDeadline = new Date(""); diff --git a/application/views/resetpw_header.php b/application/views/resetpw_header.php new file mode 100644 index 0000000..b847dee --- /dev/null +++ b/application/views/resetpw_header.php @@ -0,0 +1,11 @@ + + + + +北大赛账户密码重置 +

北大赛账户密码重置

+ + + + + diff --git a/assets/js/.Rhistory b/assets/js/.Rhistory new file mode 100644 index 0000000..e69de29 diff --git a/assets/js/race.js b/assets/js/race.js index 1f8bfe2..1738a25 100755 --- a/assets/js/race.js +++ b/assets/js/race.js @@ -184,6 +184,71 @@ function postSignup() { } +function forgetpw() { + var mail = $("#mail").val(); + + //The following part of code is for front-end validation. + + + if (mail == "") { + alert("邮箱不能为空!"); + $("#mail").focus(); + return; + } + + //Organize the data and post to the controller. + var data = { + mail: mail, + }; + $.post(controller, data, function(data) { + if (data.code == "200") { + alert("发送验证码成功!请登录您的邮箱查看激活邮件!"); + window.location.assign(directto); + } else { + alert(data.msg); + } + }) + +} + +function resetpw() { + var password = $.md5($("#password").val()); + var passconf = $.md5($("#passconf").val()); + + //The following part of code is for front-end validation. + + if (password == "") { + alert("密码不能为空!"); + $("#password").focus(); + return; + } + if (passconf == "") { + alert("请确认您的密码!"); + $("#passconf").focus(); + return; + } + if (passconf != password) { + alert("两次输入的密码不同,请重新确认!"); + $("#passconf").focus(); + return; + } + + //Organize the data and post to the controller. + var data = { + password: password, + passconf: passconf + }; + $.post(controller, data, function(data) { + if (data.code == "200") { + alert("修改密码成功!请重新登录您的账户!"); + window.location.assign(directto); + } else { + alert(data.msg); + } + }) + +} + /* * This function is called when clicking 'save'. * It will store the individual information into cookie. diff --git a/signup_success 2.php b/signup_success 2.php deleted file mode 100644 index 5aa6763..0000000 --- a/signup_success 2.php +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -注册成功 - - - -

注册成功,请登录您的邮箱查收激活邮件来激活您的帐户!
激活后管理员将于 24 小时内审核您的帐号,审核通过后即可登录!

- - - \ No newline at end of file diff --git a/signup_success.php b/signup_success.php deleted file mode 100644 index 5aa6763..0000000 --- a/signup_success.php +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -注册成功 - - - -

注册成功,请登录您的邮箱查收激活邮件来激活您的帐户!
激活后管理员将于 24 小时内审核您的帐号,审核通过后即可登录!

- - - \ No newline at end of file From c957c62ff14c428e174650b19b6c94307889fa24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=AD=90=E7=90=A6?= Date: Wed, 27 Mar 2019 16:14:43 +0800 Subject: [PATCH 4/8] addpassword backup 2019-3-27 --- application/config/constants.php | 1 + application/controllers/user.php | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/application/config/constants.php b/application/config/constants.php index ccd86d6..946f8e5 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -81,6 +81,7 @@ '400' => '存在不合法输入,请检查手机号、邮箱等信息是否正确填写!', '401' => '密码错误,请重新输入!', '402' => '邮箱有误,请重新输入!', + '403' => '重置密码激活链接已成功发送,请查收!', // Individual Registration Error. '999' => '人员名单不能为空。', '1000' => '第{order}个人的姓名不合法。', diff --git a/application/controllers/user.php b/application/controllers/user.php index 497f65c..74e64ec 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -139,10 +139,12 @@ public function forgetpw() { $err_code = '202'; } else { $err_code = '200'; - unset($data['passconf']); - $token = $this->user->generate_token($data['mail']); - $data = array_merge($data, array('token' => $token)); - $this->email->send_account_confirm_mail($data['mail']); + + $token = $this->user->generate_token($user_info['mail']); + + $data = array_merge($user_info, array('token' => $token)); + $this->email->send_resetpw_confirm_mail($user_info['mail']); + } exit(err_msg($err_code)); } From 7af95996f9d8a11eb1841e7f73a695e5f28f0734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=AD=90=E7=90=A6?= Date: Wed, 27 Mar 2019 19:44:01 +0800 Subject: [PATCH 5/8] addpassword backup 2019-3-27 --- application/.DS_Store | Bin 10244 -> 0 bytes application/controllers/user.php | 13 +++++-------- application/libraries/MY_Email.php | 2 ++ application/models/user_model.php | 4 ++-- ...w_header.php => resetpw_activate_header.php} | 0 resetpw_activate_info.php | 1 + 6 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 application/.DS_Store rename application/views/{resetpw_header.php => resetpw_activate_header.php} (100%) create mode 100644 resetpw_activate_info.php diff --git a/application/.DS_Store b/application/.DS_Store deleted file mode 100644 index 71aff0d174eec17e29ab04ac46caae2506c7abe7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHMTWl0n82BoQ_G;)4&qXw(Ov^gnZEm))fpBm~9GZ07uD z{>!<1=bL}`oCN^vOsQdjAOHw-Gbxu-G0(;9?7r$M@-zXGNbvwVjK!zy$+%&~uk!X4 zJ_0@hJ_0@hJ_0@h{{;l-JDXiX8JB+PBj6+8BalUa<%b~MOh!F9$EBM(sBpIcB#TMy zUR0-jfEyF^WYm*$T)LsuCf_}v7mD5%19>>vgUp>|)RS{u@^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x!)kd<);f_wXb948Opy@EamZ zScc`e9Ph%_xCYnadThdGY{fR*f<4%a+prJ&aRhhcUK~XgC(y)0n8X=;5}(4S@fmyx zPvfh22G8SL_%6PW7x>7ESjuD9gIr`v{FrJvOeIQsNBl+m=A&e7Pp`D?-=XB!<&1}w zOYT^@Y-L^jhQ^jn4`i3HVAb-7mCGiVK%5~ib27}}j15#RuU>JdR69hR(he80Ji~r@ zA!CnliFvOI*4E05HvCasQ!5d#Mc1}&4cUr3OQ?Y?3y8wp7LG`@atX1O$F;Uel3Yx5 z=GM(y$XZIo<<@8iS%JM+;y-8J88`>;5$nE$%fz)G;3s0+AMhuZU=UxC3|MAP(U!jG=-F;+#gDniNxaNgBFt`JVwdd@AYh|NZ^{|6~9E7iTP^SpWb4 diff --git a/application/controllers/user.php b/application/controllers/user.php index 74e64ec..2800b1c 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -132,21 +132,18 @@ public function forgetpw() { } $user_info = $this->user->get_user_by_email($login_info['mail']); if ($user_info == NULL) { - $err_code = '204'; + exit(err_msg('204')); } elseif (!$user_info['activated']) { - $err_code = '201'; + exit(err_msg('201')); } elseif (!$user_info['confirmed']) { - $err_code = '202'; + exit(err_msg('202')); } else { $err_code = '200'; - $token = $this->user->generate_token($user_info['mail']); - $data = array_merge($user_info, array('token' => $token)); $this->email->send_resetpw_confirm_mail($user_info['mail']); - - } - exit(err_msg($err_code)); + } + exit(err_msg('403')); } } /* diff --git a/application/libraries/MY_Email.php b/application/libraries/MY_Email.php index 3a043c2..7327ecc 100644 --- a/application/libraries/MY_Email.php +++ b/application/libraries/MY_Email.php @@ -69,6 +69,7 @@ public function send_account_confirm_mail($mail) { } public function send_resetpw_confirm_mail($mail) { + $subject = '第十七届全国高校自行车交流赛帐户修改密码'; $token = $this->ci->user->get_token($mail); $link = site_url('user/resetpw_activate') . '/' . $token; @@ -76,6 +77,7 @@ public function send_resetpw_confirm_mail($mail) { $id_message='

贵高校本次比赛的ID是' . $id . '

祝好!

北京大学自行车协会'; $message = '请点击以下链接重置帐户密码' . $link . $id_message; $this->send_mail($mail, $subject, $message); + } diff --git a/application/models/user_model.php b/application/models/user_model.php index 2700494..9276d0a 100644 --- a/application/models/user_model.php +++ b/application/models/user_model.php @@ -243,7 +243,7 @@ public function activate($token) { } } -public function resetpw_activate($token) { + public function resetpw_activate($token) { if (!$token) { return 2; } else { @@ -256,7 +256,7 @@ public function resetpw_activate($token) { } } } - + /* * This function freezes a certain user. */ diff --git a/application/views/resetpw_header.php b/application/views/resetpw_activate_header.php similarity index 100% rename from application/views/resetpw_header.php rename to application/views/resetpw_activate_header.php diff --git a/resetpw_activate_info.php b/resetpw_activate_info.php new file mode 100644 index 0000000..8e0fba7 --- /dev/null +++ b/resetpw_activate_info.php @@ -0,0 +1 @@ +

\ No newline at end of file From 374df0963503fa0826083a7b7e7f79b058bba9e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=AD=90=E7=90=A6?= Date: Fri, 29 Mar 2019 13:02:17 +0800 Subject: [PATCH 6/8] addpassword backup 2019-3-27 --- application/controllers/user.php | 3 +- application/views/resetpw_activate_header.php | 5 +- application/views/resetpw_activate_info.php | 53 ++++++++++++++++++- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/application/controllers/user.php b/application/controllers/user.php index 2800b1c..37be886 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -139,8 +139,7 @@ public function forgetpw() { exit(err_msg('202')); } else { $err_code = '200'; - $token = $this->user->generate_token($user_info['mail']); - $data = array_merge($user_info, array('token' => $token)); + $token = $this->user->set_token($user_info['mail']); $this->email->send_resetpw_confirm_mail($user_info['mail']); } exit(err_msg('403')); diff --git a/application/views/resetpw_activate_header.php b/application/views/resetpw_activate_header.php index b847dee..66bae66 100644 --- a/application/views/resetpw_activate_header.php +++ b/application/views/resetpw_activate_header.php @@ -2,10 +2,7 @@ -北大赛账户密码重置 -

北大赛账户密码重置

+北大赛账户激活 - - diff --git a/application/views/resetpw_activate_info.php b/application/views/resetpw_activate_info.php index 8e0fba7..b327d02 100644 --- a/application/views/resetpw_activate_info.php +++ b/application/views/resetpw_activate_info.php @@ -1 +1,52 @@ -

\ No newline at end of file + +
+

重置密码

+
+ +
+ +


+ +
+ +


+
+
+ +
+
+ +
+
+ From 86b74720044070138cc5ed1fa79d6e2909aabe04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=AD=90=E7=90=A6?= Date: Fri, 29 Mar 2019 22:09:38 +0800 Subject: [PATCH 7/8] addpassword backup 2019-3-29 --- application/controllers/user.php | 59 ++++++++++++++++----- application/views/resetpw_activate_info.php | 9 +++- application/views/resetpw_form.php | 42 ++++++++++----- 3 files changed, 83 insertions(+), 27 deletions(-) diff --git a/application/controllers/user.php b/application/controllers/user.php index 37be886..8ab5465 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -145,6 +145,43 @@ public function forgetpw() { exit(err_msg('403')); } } + + public function resetpw() { + + if ($this->input->server('REQUEST_METHOD') == 'GET') { + if ($this->session->userdata('logged_in')) { + redirect(base_url(), 'refresh'); + } + $this->load->view('header_homepage'); + $this->load->view('add_hilight_nav2'); + $this->load->view('resetpw_form'); + $this->load->view('footer'); + } + + if ($this->input->server('REQUEST_METHOD') == 'POST') { + $login_info = $this->input->post(); + + header('Content-Type: application/json'); + if ($this->form_validation->run('resetpw') == false) { + $err_code = '400'; + exit(err_msg($err_code)); + } + $user_info = $this->user->get_user_by_email($login_info['mail']); + if ($user_info == NULL) { + exit(err_msg('204')); + } elseif (!$user_info['activated']) { + exit(err_msg('201')); + } elseif (!$user_info['confirmed']) { + exit(err_msg('202')); + } else { + $err_code = '200'; + $token = $this->user->set_token($user_info['mail']); + $this->email->send_resetpw_confirm_mail($user_info['mail']); + } + exit(err_msg('403')); + } + } + /* * Show registration result for the user. */ @@ -231,20 +268,18 @@ public function activate() { $this->load->view('activate_footer'); } -public function resetpw_activate() { + public function resetpw_activate() { + $this->load->model('user_model', 'user'); $token = $this->uri->segment(3); - $this->load->view('resetpw_activate_header'); - $status = $this->user->resetpw_activate($token); - $data = array('info' => ''); - if ($status == 0) - $data['info'] = '重置密码激活成功!'; - elseif ($status == 1) - $data['info'] = '激活码无效或您已成功激活。'; - elseif ($status == 2) - $data['info'] = '激活码不存在。'; - $this->load->view('resetpw_activate_info', $data); - $this->load->view('resetpw_activate_footer'); + $status = $this->user->activate($token); + $data = array('status' => $status); + $this->load->view('header_homepage'); + $this->load->view('resetpw_form',$data); + $this->load->view('footer'); + + + } /* diff --git a/application/views/resetpw_activate_info.php b/application/views/resetpw_activate_info.php index b327d02..8fe4ced 100644 --- a/application/views/resetpw_activate_info.php +++ b/application/views/resetpw_activate_info.php @@ -5,6 +5,13 @@

重置密码


+ + + + + + +
@@ -18,7 +25,7 @@
- +
-
-

重置密码

-
- -
+ + +
+

重置密码

+
+ +
-


- -
+


+ +
-


-
-
+


+
+
-
-
+
+
+
-
+
+ + + +

激活码无效或您已成功激活。

+
+ + +

激活码不存在。

+
+ +