Ejemplo n.º 1
0
 public function unsubscribe(User $user)
 {
     $s = EmailListSubscription::where('user_id', $user->id)->where('list_id', $this->id);
     if (!$s) {
         return false;
     }
     $s->delete();
     return true;
 }
Ejemplo n.º 2
0
 public function unsubscribeLink(Request $request, $hash)
 {
     $data = EmailList::parseUnsubscribeHash($hash);
     $user = User::findOrFail($data->user);
     $list = EmailList::findOrFail($data->list);
     $sub = EmailListSubscription::where('user_id', $user->id)->where('list_id', $list->id)->first();
     if ($sub != null) {
         $request->session()->flash('flash_message', $user->name . ' has been unsubscribed from ' . $list->name);
         $sub->delete();
     } else {
         $request->session()->flash('flash_message', $user->name . ' was already unsubscribed from ' . $list->name);
     }
     return Redirect::route('homepage');
 }
Ejemplo n.º 3
0
 public function deleteUser(Request $request, $id)
 {
     $user = User::findOrFail($id);
     if ($user->id != Auth::id() && !Auth::user()->can('board')) {
         abort(403);
     }
     if ($user->member) {
         $request->session()->flash('flash_message', 'You cannot delete your account while you are a member.');
         return Redirect::back();
     }
     Address::where('user_id', $user->id)->delete();
     Bank::where('user_id', $user->id)->delete();
     EmailListSubscription::where('user_id', $user->id)->delete();
     AchievementOwnership::where('user_id', $user->id)->delete();
     Alias::where('user_id', $user->id)->delete();
     RfidCard::where('user_id', $user->id)->delete();
     WelcomeMessage::where('user_id', $user->id)->delete();
     if ($user->photo) {
         $user->photo->delete();
     }
     $user->password = null;
     $user->remember_token = null;
     $user->birthdate = null;
     $user->gender = null;
     $user->nationality = null;
     $user->phone = null;
     $user->website = null;
     $user->utwente_username = null;
     $user->tfa_totp_key = null;
     $user->tfa_yubikey_identity = null;
     $user->phone_visible = 0;
     $user->address_visible = 0;
     $user->receive_sms = 0;
     $user->save();
     $user->delete();
     $request->session()->flash('flash_message', 'Your account has been deleted.');
     return Redirect::route('homepage');
 }