File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
laravel/app/Http/Controllers/Api Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -126,8 +126,8 @@ public function edit($id)
126
126
*/
127
127
public function update (Update $ request , $ id )
128
128
{
129
- if (env ( ' APP_ENV ' ) == ' demo ' && $ id == User:: ADMIN_ID ) {
130
- return $ this ->out (4000 , [], 'Password modification is not allowed for demo account ' );
129
+ if ($ this -> demoForbid ( $ id) ) {
130
+ return $ this ->out (4000 , [], 'demo account Do Not Operate ' );
131
131
}
132
132
$ user = User::findOrFail ($ id );
133
133
// 新增角色操作
@@ -161,6 +161,9 @@ public function update(Update $request, $id)
161
161
*/
162
162
public function destroy ($ id )
163
163
{
164
+ if ($ this ->demoForbid ($ id )) {
165
+ return $ this ->out (4000 , [], 'demo account Do Not Operate ' );
166
+ }
164
167
if (User::findOrFail ($ id )->delete ()) {
165
168
$ data = ['msg ' => '删除成功 ' , 'errno ' => 0 ];
166
169
} else {
@@ -190,4 +193,17 @@ public function getEmail()
190
193
$ faker = \Faker \Factory::create ();
191
194
return $ faker ->email ;
192
195
}
196
+
197
+ /**
198
+ * demo do not operate
199
+ * @param $id
200
+ * @return bool
201
+ */
202
+ private function demoForbid ($ id )
203
+ {
204
+ if (env ('APP_ENV ' ) == 'demo ' && $ id == User::ADMIN_ID ) {
205
+ return false ;
206
+ }
207
+ return true ;
208
+ }
193
209
}
You can’t perform that action at this time.
0 commit comments