public function updateSsPwd($request, $response, $args) { $user = Auth::getUser(); $pwd = $request->getParam('sspwd'); $user->updateSsPwd($pwd); $res['ret'] = 1; return $response->getBody()->write(json_encode($res)); }
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next) { $user = AuthService::getUser(); if (!$user->isLogin) { $newResponse = $response->withStatus(302)->withHeader('Location', '/auth/login'); return $newResponse; } $response = $next($request, $response); return $response; }
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next) { //$response->getBody()->write('BEFORE'); $user = AuthService::getUser(); if ($user->isLogin) { // @TODO login action } $response = $next($request, $response); //$response->getBody()->write('AFTER'); return $response; }
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, $next) { //$response->getBody()->write('BEFORE'); $user = AuthService::getUser(); if (!$user->isLogin) { // @TODO no login action $response->getBody()->write('Access Denied'); // $next = 'App\Controllers\HomeController:home'; return $response; } $response = $next($request, $response); //$response->getBody()->write('AFTER'); return $response; }
public function doCheckin($request, $response, $args) { $user = Auth::getUser(); //权限检查 if (!$user->isAbleToCheckin()) { $tranferToAdd = 0; $res['msg'] = "签到过了哦"; return $response->getBody()->write(json_encode($res)); } $tranferToAdd = rand(Config::get('checkinMin'), Config::get('checkinMax')); // Add transfer $user->addTraffic($tranferToAdd); $res['msg'] = "获得了" . $tranferToAdd . "MB流量"; return $response->getBody()->write(json_encode($res)); }
public static function getSmarty() { $smarty = new smarty(); //实例化smarty $smarty->settemplatedir(BASE_PATH . '/resources/views/' . Config::get('theme') . '/'); //设置模板文件存放目录 $smarty->setcompiledir(BASE_PATH . '/storage/framework/smarty/compile/'); //设置生成文件存放目录 $smarty->setcachedir(BASE_PATH . '/storage/framework/smarty/cache/'); //设置缓存文件存放目录 // add config $smarty->assign('config', Config::getPublicConfig()); $smarty->assign('user', Auth::getUser()); return $smarty; }
public function smarty() { global $config; $smarty = new smarty(); //实例化smarty $smarty->settemplatedir(BASE_PATH . '/views/' . $config['theme'] . '/'); //设置模板文件存放目录 $smarty->setcompiledir(BASE_PATH . '/storage/framework/smarty/compile/'); //设置生成文件存放目录 $smarty->setcachedir(BASE_PATH . '/storage/framework/smarty/cache/'); //设置缓存文件存放目录 // add config $smarty->assign('config', $config); $smarty->assign('user', Auth::getUser()); $this->smarty = $smarty; return $smarty; }
public function handleKill($request, $response, $args) { $user = Auth::getUser(); $passwd = $request->getParam('passwd'); // check passwd $res = array(); if (!Hash::checkPassword($user->pass, $passwd)) { $res['ret'] = 0; $res['msg'] = " 密码错误"; return $this->echoJson($response, $res); } Auth::logout(); $user->delete(); $res['ret'] = 1; $res['msg'] = "GG!您的帐号已经从我们的系统中删除."; return $this->echoJson($response, $res); }
public function updateMethod($request, $response, $args) { $user = Auth::getUser(); $method = $request->getParam('method'); $method = strtolower($method); $user->updateMethod($method); $res['ret'] = 1; return $response->getBody()->write(json_encode($res)); }
public function updateSsPwd($request, $response, $next) { $user = Auth::getUser(); $pwd = $request->getParam('sspwd'); $user->updateSsPwd($pwd); }