From f627497a721e5e5e718fc88dbf59da19158cf1e5 Mon Sep 17 00:00:00 2001 From: orvice Date: Wed, 6 Jan 2016 01:36:02 +0800 Subject: [PATCH 1/5] init node manage --- app/Controllers/Admin/NodeController.php | 14 ++++- config/routes.php | 3 +- views/default/admin/node.tpl | 74 ++++++++++-------------- views/default/admin/sys.tpl | 4 +- 4 files changed, 48 insertions(+), 47 deletions(-) diff --git a/app/Controllers/Admin/NodeController.php b/app/Controllers/Admin/NodeController.php index bb495f065..73cb7933e 100644 --- a/app/Controllers/Admin/NodeController.php +++ b/app/Controllers/Admin/NodeController.php @@ -2,9 +2,21 @@ namespace App\Controllers\Admin; -class NodeController +use App\Models\Node; +use App\Controllers\BaseController; + +class NodeController extends BaseController { public function index(){ + $nodes = Node::all(); + return $this->view()->assign('nodes',$nodes)->display('admin/node.tpl'); + } + + public function create(){ + + } + + public function edit(){ } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index c199f177a..14b2beac2 100755 --- a/config/routes.php +++ b/config/routes.php @@ -61,7 +61,8 @@ $app->group('/admin', function () { $this->get('', 'App\Controllers\AdminController:index'); $this->get('/', 'App\Controllers\AdminController:index'); - $this->get('/node', 'App\Controllers\AdminController:node'); + $this->get('/node', 'App\Controllers\Admin\NodeController:index'); + $this->get('/node/create', 'App\Controllers\Admin\NodeController:create'); $this->get('/profile', 'App\Controllers\AdminController:profile'); $this->get('/invite', 'App\Controllers\AdminController:invite'); $this->post('/invite', 'App\Controllers\AdminController:addInvite'); diff --git a/views/default/admin/node.tpl b/views/default/admin/node.tpl index b7b6a9314..a0830e71d 100755 --- a/views/default/admin/node.tpl +++ b/views/default/admin/node.tpl @@ -1,4 +1,4 @@ -{include file='user/main.tpl'} +{include file='admin/main.tpl'}
@@ -12,53 +12,41 @@
-
-
-
-
- -

节点

-
-
-
-

注意!

-

请勿在任何地方公开节点地址!

-
- {foreach $nodes as $node} - - {/foreach} +
+

添加

+
+
+ + + + + + + + + + {foreach $nodes as $node} + + + + + + + + + {/foreach} +
ID节点加密描述排序操作
#{$node->id} {$node->name}{$node->method}{$node->info}{$node->order} + 编辑 + 删除 +
- -
-
- -
-
+
+
-
-
-{include file='user/footer.tpl'} \ No newline at end of file +{include file='admin/footer.tpl'} \ No newline at end of file diff --git a/views/default/admin/sys.tpl b/views/default/admin/sys.tpl index 24b09616d..e684716d3 100755 --- a/views/default/admin/sys.tpl +++ b/views/default/admin/sys.tpl @@ -1,4 +1,4 @@ -{include file='user/main.tpl'} +{include file='admin/main.tpl'}
@@ -23,4 +23,4 @@
-{include file='user/footer.tpl'} \ No newline at end of file +{include file='admin/footer.tpl'} \ No newline at end of file From e1f906775dfac988e7a4eb0c66f5ac41574ff8f1 Mon Sep 17 00:00:00 2001 From: orvice Date: Sun, 17 Jan 2016 14:29:09 +0800 Subject: [PATCH 2/5] add password reset --- app/Controllers/Password.php | 19 ----- app/Controllers/PasswordController.php | 31 ++++++++ app/Services/Mail.php | 5 +- config/routes.php | 8 ++ views/default/password/reset.tpl | 104 +++++++++++++++++++++++++ 5 files changed, 147 insertions(+), 20 deletions(-) delete mode 100644 app/Controllers/Password.php create mode 100644 app/Controllers/PasswordController.php diff --git a/app/Controllers/Password.php b/app/Controllers/Password.php deleted file mode 100644 index 167cf7bf3..000000000 --- a/app/Controllers/Password.php +++ /dev/null @@ -1,19 +0,0 @@ -view()->display('password/reset.tpl'); + } + + public function handleReset($request, $response, $next){ + $email = $request->getParam('email'); + // check limit + + // send email + + $rs['ret'] = 1; + $rs['msg'] = 'ok'; + return $response->getBody()->write(json_encode($rs)); + } + + public function handleToken($request, $response, $next){ + + } +} \ No newline at end of file diff --git a/app/Services/Mail.php b/app/Services/Mail.php index 685bb3d26..9db150af2 100755 --- a/app/Services/Mail.php +++ b/app/Services/Mail.php @@ -2,7 +2,10 @@ namespace App\Services; -use App\Services\Config; +/*** + * Mail Service + */ + use App\Services\Mail\Mailgun; use App\Services\Mail\Smtp; diff --git a/config/routes.php b/config/routes.php index 14b2beac2..77c21edae 100755 --- a/config/routes.php +++ b/config/routes.php @@ -57,6 +57,14 @@ $this->get('/logout', 'App\Controllers\AuthController:logout'); })->add(new Guest()); +// Password +$app->group('/password', function () { + $this->get('/reset', 'App\Controllers\PasswordController:reset'); + $this->post('/reset', 'App\Controllers\AuthController:handleReset'); + $this->get('/token', 'App\Controllers\AuthController:token'); + $this->post('/token', 'App\Controllers\AuthController:handleToken'); +})->add(new Guest()); + // Admin $app->group('/admin', function () { $this->get('', 'App\Controllers\AdminController:index'); diff --git a/views/default/password/reset.tpl b/views/default/password/reset.tpl index e69de29bb..622f3bcb8 100644 --- a/views/default/password/reset.tpl +++ b/views/default/password/reset.tpl @@ -0,0 +1,104 @@ +{include file='auth/header.tpl'} + + + + + + + + + + + + + \ No newline at end of file From b2ee12d1a386d9168ed849e613d0c82c895be6c5 Mon Sep 17 00:00:00 2001 From: orvice Date: Sun, 17 Jan 2016 15:01:43 +0800 Subject: [PATCH 3/5] fix --- app/Controllers/PasswordController.php | 12 ++++++++++-- app/Services/Password.php | 21 +++++++++++++++++++++ config/routes.php | 6 +++--- views/default/password/reset.tpl | 18 ++++++++---------- 4 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 app/Services/Password.php diff --git a/app/Controllers/PasswordController.php b/app/Controllers/PasswordController.php index 991199be5..9d256f358 100644 --- a/app/Controllers/PasswordController.php +++ b/app/Controllers/PasswordController.php @@ -2,6 +2,8 @@ namespace App\Controllers; +use App\Models\User; +use App\Services\Password; /*** * Class Password * @package App\Controllers @@ -19,9 +21,15 @@ public function handleReset($request, $response, $next){ // check limit // send email - + $user = User::where('email',$email)->first(); + if ($user == null){ + $rs['ret'] = 0; + $rs['msg'] = '此邮箱不存在.'; + return $response->getBody()->write(json_encode($rs)); + } + Password::sendResetEmail($email); $rs['ret'] = 1; - $rs['msg'] = 'ok'; + $rs['msg'] = '重置邮件已经发送,请检查邮箱.'; return $response->getBody()->write(json_encode($rs)); } diff --git a/app/Services/Password.php b/app/Services/Password.php new file mode 100644 index 000000000..def0ac46d --- /dev/null +++ b/app/Services/Password.php @@ -0,0 +1,21 @@ +group('/password', function () { $this->get('/reset', 'App\Controllers\PasswordController:reset'); - $this->post('/reset', 'App\Controllers\AuthController:handleReset'); - $this->get('/token', 'App\Controllers\AuthController:token'); - $this->post('/token', 'App\Controllers\AuthController:handleToken'); + $this->post('/reset', 'App\Controllers\PasswordController:handleReset'); + $this->get('/token', 'App\Controllers\PasswordController:token'); + $this->post('/token', 'App\Controllers\PasswordController:handleToken'); })->add(new Guest()); // Admin diff --git a/views/default/password/reset.tpl b/views/default/password/reset.tpl index 622f3bcb8..6587a26cf 100644 --- a/views/default/password/reset.tpl +++ b/views/default/password/reset.tpl @@ -17,12 +17,12 @@
- +