$request['account']])->findOrEmpty(); if ($student->isEmpty()) { throw new Exception('账号不存在'); } if (empty($request['password'])) { throw new Exception('请填写密码'); } if (md5($request['password'] . $student->salt) != $student->password) { throw new Exception('密码错误,请填写正确的密码'); } $token_data = [ 'id' => $student->id, 'role' => 'parent' ]; $token = JwtToken::generateToken($token_data); return [ 'code' => ResponseCode::SUCCESS, 'data' => $token, 'msg' => 'success' ]; } catch (Exception $e) { return [ 'code' => ResponseCode::FAIL, 'msg' => $e->getMessage() ]; } } }