Esempio n. 1
0
 public function postLogin(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'password' => 'required']);
     $credentials = $request->only('name', 'password');
     try {
         $user = user::where('name', '=', $credentials['name'])->firstOrFail();
     } catch (ModelNotFoundException $e) {
         return redirect('/')->withInput($request->only('name', 'remember'))->withErrors(['name' => 'These credentials do not match our records.']);
     }
     if ($user) {
         session()->regenerate();
         Session::set('user', $user);
         $group = group::find($user->groupid);
         if ($group->count()) {
             Session::set('group', $group);
             $privileges = privileges_group::select('p.privilegesid as id', 'p.privilegesname as name', 'p.privilegesdesc as desc')->leftJoin('mprivileges as p', 'p.privilegesid', '=', 'mprivileges_group.privilegesid')->where('mprivileges_group.groupid', '=', $group->groupid)->get();
             Session::set('privileges', $privileges);
         }
     }
     if ($this->auth->attempt($credentials, $request->has('remember'))) {
         return redirect('/admin');
     }
     return redirect('/')->withInput($request->only('name', 'remember'))->withErrors(['password' => 'Password is wrong']);
 }
Esempio n. 2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     if (null === \Config::get('group')) {
         return redirect('/admin');
     }
     $grouplvl = array();
     if (\Config::get('group') == -1) {
         $groups = group::where('status', '>', 0)->get();
     } else {
         $groups = group::where('status', '>', 0)->where('groupid', '>', 0)->get();
     }
     foreach ($groups as $g) {
         if ($g->parent == 0) {
             $grouplvl[$g->groupid] = $g->groupname;
             $this->getChildGroup($groups, $g->groupid, $grouplvl);
         }
     }
     $user = user::find($id);
     return view('admin.master.user.user-edit')->with('user', $user)->with('groups', $grouplvl);
 }
Esempio n. 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $user = user::where('groupid', '=', $id);
     if ($user->count()) {
         $errors[] = 'maaf, group ini dipakai oleh beberapa group, jika anda yakin, mohon hapus user yang terkait dengan group ini';
         return redirect()->back()->withErrors($errors);
     }
     $group = group::find($id);
     $groupchild = group::where('parent', '=', $id);
     if ($groupchild->count()) {
         $errors[] = 'maaf, group ini memiliki sub group!';
         return redirect()->back()->withErrors($errors);
     }
     //Clear permission for this group
     \DB::table('mprivileges_group')->where('groupid', '=', $id)->delete();
     $group->delete();
     return redirect('/admin/group');
 }
Esempio n. 4
0
 /**
  * Get all user groups available
  *
  * @return array
  * @author Y.Brahmantyo. AK
  **/
 public function getGroups()
 {
     $output = group::where('groupid', '>', 0)->get();
     return json_encode($output);
 }