Ejemplo n.º 1
0
 /**
  * logout method gets user details from the Auth::user and removes api token from db and send back notification. 
  * @return Notification
  */
 public function logout()
 {
     $user = Auth::user();
     if (!empty($user)) {
         $user->api_token = null;
         $user->save();
     }
     $notice = new Notification();
     $notice->notify("Logged Out", 1000, "warning");
     return $this->respondWithCORS($notice);
 }
Ejemplo n.º 2
0
 /**
  * Validate and Send email to user
  * @param Request
  * @return Notification
  */
 public function forgotPassword(Request $request)
 {
     $this->validate($request, ['username' => 'required']);
     $user = User::where('email', $request->input("username"))->orWhere('username', $request->input("username"))->first();
     if (!empty($user)) {
         // @todo email implementation goes here
         $success = new Notification();
         $success->notify("We have sent an email to your registered email. Please follow the steps to reset your password.", 5200, "success");
         return $this->respondWithCORS($success);
     } else {
         $error = new Notification();
         $error->notify("User not found.", 5200);
         return $this->respondWithCORS($error);
     }
 }
Ejemplo n.º 3
0
 /**
  * Delete the user by user_id
  * @param User
  * @return Notification
  */
 public function deleteUser($user_id)
 {
     $user = User::where('user_id', $user_id)->first();
     if (!empty($user)) {
         $user->delete();
         $success = new Notification();
         $success->notify("User deleted.", 5102, "success");
         return $this->respondWithCORS($success);
     } else {
         $error = new Notification();
         $error->notify("User not found.", 5103);
         return $this->respondWithCORS($error);
     }
 }