@@ -484,4 +484,49 @@ public function getDatatable()
484484 ->make ();
485485 }
486486
487+ /**
488+ * Unsuspend the given user.
489+ *
490+ * @param int $id
491+ * @return Redirect
492+ */
493+ public function getUnsuspend ($ id = null )
494+ {
495+ try {
496+ // Get user information
497+ $ user = Sentry::getUserProvider ()->findById ($ id );
498+
499+ // Check if we are not trying to unsuspend ourselves
500+ if ($ user ->id === Sentry::getId ()) {
501+ // Prepare the error message
502+ $ error = Lang::get ('admin/users/message.error.unsuspend ' );
503+
504+ // Redirect to the user management page
505+ return Redirect::route ('users ' )->with ('error ' , $ error );
506+ }
507+
508+ // Do we have permission to unsuspend this user?
509+ if ($ user ->isSuperUser () and ! Sentry::getUser ()->isSuperUser ()) {
510+ // Redirect to the user management page
511+ return Redirect::route ('users ' )->with ('error ' , 'Insufficient permissions! ' );
512+ }
513+
514+ // Unsuspend the user
515+ $ throttle = Sentry::findThrottlerByUserId ($ id );
516+ $ throttle ->unsuspend ();
517+
518+ // Prepare the success message
519+ $ success = Lang::get ('admin/users/message.success.unsuspend ' );
520+
521+ // Redirect to the user management page
522+ return Redirect::route ('users ' )->with ('success ' , $ success );
523+ } catch (UserNotFoundException $ e ) {
524+ // Prepare the error message
525+ $ error = Lang::get ('admin/users/message.user_not_found ' , compact ('id ' ));
526+
527+ // Redirect to the user management page
528+ return Redirect::route ('users ' )->with ('error ' , $ error );
529+ }
530+ }
531+
487532}
0 commit comments