Beispiel #1
0
 public function updatePassword(UpdatePasswordRequest $request, User $user)
 {
     $user->update(['password' => $request->get('password')]);
     Log::info($message = 'The password was updated successfully !', $user->toArray());
     $this->notifySuccess($message, 'Password Updated !');
     return redirect()->route('admin::auth.profile.index');
 }
 /**
  * Start the user impersonation.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return bool
  */
 public static function start(User $user)
 {
     if (!$user->canBeImpersonated()) {
         return false;
     }
     session()->put(self::getKey(), $user->id);
     return true;
 }
Beispiel #3
0
 public function updatePassword(UpdatePasswordRequest $request, User $user)
 {
     $user->password = $request->get('password');
     $user->save();
     $message = 'The password was updated successfully !';
     Log::info($message, $user->toArray());
     $this->notifySuccess($message, 'Password Updated !');
     return redirect()->route('auth::foundation.profile.index');
 }
Beispiel #4
0
 /**
  * Eloquent 'deleting' event method.
  *
  * @param  \Arcanedev\LaravelAuth\Models\User|User  $user
  *
  * @return bool
  */
 public function deleting(User $user)
 {
     if ($user->isAdmin()) {
         return false;
     }
     if ($user->isForceDeleting()) {
         $user->roles()->detach();
     }
     $this->event->fire('auth.users.deleting', compact('user'));
     return true;
 }
Beispiel #5
0
 /**
  * Confirm user account.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return \Arcanesoft\Contracts\Auth\Models\User
  */
 public function confirm(UserContract $user)
 {
     event('auth.users.confirming', compact('user'));
     $user->setAttribute('is_confirmed', true);
     $user->setAttribute('confirmation_code', null);
     $user->setAttribute('confirmed_at', Carbon::now());
     $user->save();
     event('auth.users.confirmed', compact('user'));
     return $user;
 }
Beispiel #6
0
 /**
  * Check the user is allowed to see this item.
  *
  * @return bool
  */
 public function allowed()
 {
     if ($this->user->isAdmin()) {
         return true;
     }
     if (empty($this->roles) && empty($this->permissions)) {
         return true;
     }
     foreach ($this->roles as $roleSlug) {
         if ($this->user->hasRoleSlug($roleSlug)) {
             return true;
         }
     }
     foreach ($this->permissions as $permissionSlug) {
         if ($this->user->may($permissionSlug)) {
             return true;
         }
     }
     return false;
 }
 /**
  * Allow to delete a password reset.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return bool
  */
 public function deletePolicy(User $user)
 {
     return $user->may(static::PERMISSION_DELETE);
 }
Beispiel #8
0
 /**
  * Allow to delete a category.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return bool
  */
 public function deletePolicy(User $user)
 {
     return $user->may('blog.categories.delete');
 }
Beispiel #9
0
 /**
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  * @param  mixed                                   $ability
  *
  * @return bool
  */
 public function before(User $user, $ability)
 {
     if ($user->isAdmin()) {
         return true;
     }
 }
Beispiel #10
0
 /**
  * Allow to access all the auth stats.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return bool
  */
 public function statsPolicy(User $user)
 {
     return $user->may(static::PERMISSION_STATS);
 }
Beispiel #11
0
 /**
  * Delete a user.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function delete(User $user)
 {
     self::onlyAjax();
     $this->authorize(UsersPolicy::PERMISSION_DELETE);
     try {
         if ($user->trashed()) {
             $user->forceDelete();
             $message = "The user {$user->username} has been successfully deleted !";
             Log::info($message, $user->toArray());
         } else {
             $user->delete();
             $message = "The user {$user->username} was placed in trashed users !";
         }
         $this->notifySuccess($message, 'User deleted !');
         $ajax = ['status' => 'success', 'message' => $message];
     } catch (\Exception $e) {
         $ajax = ['status' => 'error', 'message' => $e->getMessage()];
     }
     return response()->json($ajax);
 }
Beispiel #12
0
 /**
  * Allow to delete a tag.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return bool
  */
 public function deletePolicy(User $user)
 {
     return $user->may('blog.tags.delete');
 }
Beispiel #13
0
 /**
  * Check if the user is allowed.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return bool
  */
 private function isAllowed($user)
 {
     return $user->isAdmin() || $user->isModerator();
 }
Beispiel #14
0
 /**
  * Allow to update a role.
  *
  * @param  \Arcanesoft\Contracts\Auth\Models\User  $user
  *
  * @return bool
  */
 public function updatePolicy(User $user)
 {
     return $user->may(static::PERMISSION_UPDATE);
 }