生成分享链接并且生成token
Showing
3 changed files
with
12 additions
and
3 deletions
... | @@ -35,7 +35,7 @@ class ErrorCode | ... | @@ -35,7 +35,7 @@ class ErrorCode |
35 | const INVALID_TIMESTAMP = 40016; | 35 | const INVALID_TIMESTAMP = 40016; |
36 | const INVALID_NONCE = 40017; | 36 | const INVALID_NONCE = 40017; |
37 | const MISSING_PARAMS = 41000; | 37 | const MISSING_PARAMS = 41000; |
38 | 38 | const URL_CHECK_FAIL = 42000; | |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * @var string[] | 41 | * @var string[] |
... | @@ -68,7 +68,8 @@ class ErrorCode | ... | @@ -68,7 +68,8 @@ class ErrorCode |
68 | self::EMPTY_PARAMS => '部分参数为空', | 68 | self::EMPTY_PARAMS => '部分参数为空', |
69 | self::INVALID_TIMESTAMP => '时间戳timestamp已失效', | 69 | self::INVALID_TIMESTAMP => '时间戳timestamp已失效', |
70 | self::INVALID_NONCE => '重复的nonce', | 70 | self::INVALID_NONCE => '重复的nonce', |
71 | self::MISSING_PARAMS => '缺少必填参数' | 71 | self::MISSING_PARAMS => '缺少必填参数', |
72 | self::URL_CHECK_FAIL => '验证失败', | ||
72 | ]; | 73 | ]; |
73 | 74 | ||
74 | 75 | ... | ... |
... | @@ -146,6 +146,13 @@ class PropertyTrackService extends Service | ... | @@ -146,6 +146,13 @@ class PropertyTrackService extends Service |
146 | */ | 146 | */ |
147 | public function shareCheck() | 147 | public function shareCheck() |
148 | { | 148 | { |
149 | $url = $this->request->input('url'); | ||
150 | |||
151 | if (!$res = PropertyShare::query()->where(['share_url_hash'=>crc64($url), 'from'=>$this->request->input('from')])->where('expire_time', '<=', $this->now)->first()) { | ||
152 | return Response::error(ErrorCode::URL_CHECK_FAIL); | ||
153 | } | ||
154 | |||
155 | //验证成功 - 生成token | ||
149 | 156 | ||
150 | 157 | ||
151 | return Response::success(); | 158 | return Response::success(); | ... | ... |
... | @@ -23,11 +23,12 @@ Route::group(["prefix"=>"property", "middleware"=>['auth.identifier']], function | ... | @@ -23,11 +23,12 @@ Route::group(["prefix"=>"property", "middleware"=>['auth.identifier']], function |
23 | Route::group(["prefix"=>"property"], function (){ | 23 | Route::group(["prefix"=>"property"], function (){ |
24 | Route::get('/track/share', 'PropertyTrackController@share'); | 24 | Route::get('/track/share', 'PropertyTrackController@share'); |
25 | Route::post('/track/shareCreate', 'PropertyTrackController@shareCreate'); | 25 | Route::post('/track/shareCreate', 'PropertyTrackController@shareCreate'); |
26 | Route::get('/track/shareCheck', 'PropertyTrackController@shareCheck'); | ||
26 | }); | 27 | }); |
27 | 28 | ||
28 | //资产-分享链接 | 29 | //资产-分享链接 |
29 | Route::group(["prefix"=>"property", "middleware"=>['auth.share']], function (){ | 30 | Route::group(["prefix"=>"property", "middleware"=>['auth.share']], function (){ |
30 | Route::get('/track/shareCheck', 'PropertyTrackController@shareCheck'); | 31 | |
31 | 32 | ||
32 | }); | 33 | }); |
33 | 34 | ... | ... |
-
Please register or sign in to post a comment