public function postLogin()
 {
     $u = \Pianke\Models\AdminUser::doLogin(\Request::input('username'), \Request::input('password'));
     if ($u) {
         \Session::put('adminlogin', $u);
         return redirect()->action('\\Pianke\\Http\\Controllers\\AdminHomeController@getIndex');
     } else {
         return redirect()->action('\\Pianke\\Http\\Controllers\\AdminLoginController@getLogin')->with('error', trans('admin.login_failed'));
     }
 }
Esempio n. 2
0
 public static function doLogin($acct, $pass)
 {
     $user_tmp = AdminUser::where("username", "=", $acct)->where('status', '=', true)->first();
     if (!$user_tmp) {
         return false;
     } else {
         if (\Hash::check($pass, $user_tmp['password'])) {
             return $user_tmp;
         } else {
             return false;
         }
     }
 }
Esempio n. 3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //检测是否登录,未登录跳转,登录了赋予菜单
     if (\Session::has('adminlogin')) {
         if (!env('PERMISSION_USE_CACHE', 'true')) {
             $uinfo = \Pianke\Models\AdminUser::find(\Session::get('adminlogin')->id);
             \Session::put('adminlogin', $uinfo);
             \Pianke\Models\AdminPermission::getCurPermissionArray(explode("|", $uinfo->role->permissions));
         }
         view()->share('menu', \Session::get('menu'));
     } else {
         return redirect()->action('\\Pianke\\Http\\Controllers\\AdminLoginController@getLogin');
     }
     //检测是否有权限访问操作
     if (!in_array('\\' . \Route::currentRouteAction(), \Session::get('curpermissions'))) {
         return redirect()->back()->withNotice(['type' => 'error', 'msg' => trans('admin.nopermission'), 'title' => trans('admin.permissionerror')]);
     }
     return $next($request);
 }
 public function getUserstatus()
 {
     $id = \Request::input('id');
     $s = \Request::input('s') == '1' ? 0 : 1;
     $uinfo = \Pianke\Models\AdminUser::find($id);
     if ($uinfo and $id != \Session::get('adminlogin')->id) {
         $uinfo->status = $s;
         if ($uinfo->save()) {
             return redirect()->action('\\Pianke\\Http\\Controllers\\AdminManagerController@getUserlist')->withNotice(['type' => 'success', 'msg' => '', 'title' => trans('admin.actsuccess')]);
         } else {
             return redirect()->action('\\Pianke\\Http\\Controllers\\AdminManagerController@getUserlist')->withNotice(['type' => 'error', 'msg' => trans('admin.acterror'), 'title' => trans('admin.actfailed')]);
         }
     } else {
         return redirect()->action('\\Pianke\\Http\\Controllers\\AdminManagerController@getUserlist')->withNotice(['type' => 'warning', 'msg' => trans('admin.notunactiveself'), 'title' => trans('admin.actfailed')]);
     }
 }
 public function run()
 {
     DB::table('admin_users')->delete();
     \Pianke\Models\AdminUser::create(['roleid' => 2, 'username' => 'test', 'name' => 'test', 'password' => bcrypt('love1314'), 'email' => '*****@*****.**', 'cell' => '18600127718']);
 }