Exemplo n.º 1
0
 public function __construct()
 {
     // 本地化设置
     $this->setLocale();
     // 权限判断
     $this->beforeFilter(function () {
         // 如果已经登录
         if (Auth::check()) {
             // 如果是 Ajax 请求
             if (Request::ajax()) {
                 // 记录日志
                 $this->writeActionLog();
                 // 判断权限
                 if (!$this->checkPrivileges()) {
                     return KTAnchor::showSlidMessage(Lang::get('login.You have no rights'));
                 }
                 // 返回空
                 // return;
             } else {
                 $account = Auth::user()["attributes"]["email"];
                 return view('__portal', ["locale" => $this->locale, "account" => $account]);
             }
         } else {
             // 如果是 Ajax 请求
             if (Request::ajax()) {
                 return KTAnchor::showSlidMessage(Lang::get('login.Session Timeout'));
             } else {
                 return KTAnchor::topLocation('/login');
             }
         }
     });
 }
Exemplo n.º 2
0
 public function signin()
 {
     // 是否记住
     $rember = !empty($_POST["rember"]) ? false : true;
     // 登录
     if (Auth::attempt(['email' => $_POST["account"], 'password' => $_POST["password"]], $rember)) {
         return KTAnchor::topLocation('/manager');
     } else {
         return KTAnchor::showSlidMessage(Lang::get('login.Failed'));
     }
 }