예제 #1
0
 function get_users_all_permissions($user_id)
 {
     $all_permissions = [];
     $current_user_roles = User::find($user_id)->user_roles()->get();
     foreach ($current_user_roles as $role) {
         /* all permissions of each role of user */
         $role_permissions = $role->role_permissions()->get();
         foreach ($role_permissions as $role_permission) {
             /*get permission name of each permission */
             $all_permissions[] = $role_permission->permissions->name;
         }
     }
     return $all_permissions;
 }
예제 #2
0
 public function run()
 {
     $user = \Focalworks\Users\User::create(['name' => 'Admin', 'email' => '*****@*****.**', 'password' => Hash::make('pass')]);
     \Focalworks\Users\UserRoles::create(['uid' => $user->id, 'rid' => 2]);
     \Focalworks\Users\UserRoles::create(['uid' => $user->id, 'rid' => 1]);
 }
예제 #3
0
 /**
  * Check current password and then change
  * the new password set by the admin.
  *
  * @param  Illuminate\Http\Request
  * @return redirect to change password
  */
 public function saveUserPassword(Request $request)
 {
     access_check('manage_users');
     $fields = array('password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation'));
     $validator = Validator::make($fields, User::$change_user_password_rules);
     if ($validator->fails()) {
         // send back to the page with the input data and errors
         return redirect()->back()->withInput()->withErrors($validator);
     } else {
         $user_id = $request->input('user_id');
         $user = User::find($user_id);
         // change password and send back
         $user->password = Hash::make($request->input('password'));
         $user->save();
         Session::flash('success', 'Password changed successfully.');
         return redirect()->back();
     }
 }
예제 #4
0
 /**
  * Saving the user profile data on save.
  *
  * @param  Illuminate\Http\Request
  * @return redirect back
  */
 public function saveUserProfile(Request $request)
 {
     access_check('manage_profile');
     if (!empty($request->input('name'))) {
         $user = User::find(Auth::user()->id);
         $user->name = $request->input('name');
         $user->save();
         Session::flash('success', 'Profile data changed.');
         return redirect()->back();
     } else {
         Session::flash('error', 'No data to change.');
         return redirect()->back();
     }
 }