protected function registerUserWithUrlCode(Request $request)
 {
     $array = Input::all();
     $validator = Validator::make($array, ['urlcode' => 'min:39|max:40|required', 'password' => 'min:6|required']);
     if ($validator->fails()) {
         return Response::json('wrong urlcode or password', 400);
     } else {
         $invitation = Invitation::where('urlcode', '=', $request->input('urlcode'))->first();
         if (empty($invitation)) {
             return Response::json('no invitation found', 400);
         }
         $projectId = $invitation->owner;
         $type = $invitation->type;
         $invitation->delete();
         $user = new User();
         $user->firstname = $invitation->firstname;
         $user->lastname = $invitation->lastname;
         $user->email = $invitation->email;
         $user->password = \Illuminate\Support\Facades\Hash::make($request->input('password'));
         $user->save();
         $users_projects_rel = new UserOwnsProjectRel();
         $users_projects_rel->User_FK = $user->id;
         $users_projects_rel->Project_FK = $projectId;
         $users_projects_rel->type = $type;
         $users_projects_rel->save();
     }
 }
Beispiel #2
0
 /**
  * For each invitation related to the user email, attach the account and delete the invitation
  * @param  self $user User
  * @return void
  */
 public static function processInvitations($user)
 {
     $invitations = Invitation::where('email', $user->email)->get();
     foreach ($invitations as $invitation) {
         $user->accounts()->attach($invitation->account_id, ['owner' => 0]);
         $invitation->delete();
     }
 }
 protected function deleteProjectInvitation(Request $request, $id)
 {
     $array = Input::all();
     $validator = Validator::make($array, ['email' => 'required|email']);
     if ($validator->fails()) {
         return Response::json('', 400);
     } else {
         $invitation = Invitation::where('email', '=', $request->input('email'))->first();
         if (empty($invitation)) {
             return Response::json('', 400);
         }
         $invitation->delete();
     }
 }
 private static function createInvitationToken($room, $part)
 {
     $inv = new Invitation();
     $inv->room = $room->id;
     $inv->participant = $part->id;
     \DB::transaction(function () use($inv) {
         //check for unique token before save
         do {
             $token = Str::random(32);
         } while (Invitation::where('token', '=', $token)->count() != 0);
         $inv->token = $token;
         $inv->save();
     });
     return $inv->token;
 }
 public function postSignup(SignupRequest $request)
 {
     $request['password'] = bcrypt($request['password']);
     // hash password
     //		$request['waitingPosition'] = Carbon::now();          // set date of registration as waiting position
     $user = User::create($request->all());
     // add role to user
     $role = Role::where('name', 'User')->first();
     $user->role()->associate($role);
     $user->save();
     // if there are no people in front on the waiting list and there is a plantPlot free, send and email and set canStartGardening to now
     //		$plantPlots = PlantPlot::getEmptyPlots();
     //		$usersThatCanStartGardening = User::getUsersThatCanStartGardening();
     //		if (count($plantPlots) != 0 && count($plantPlots) > count($usersThatCanStartGardening))   // if there is a plot free and there are no users that canStartGardening for this plot
     //		{
     //			// get user first on waiting list
     //			$firstUserInLine = User::getFirstUserInWaitingList();
     //
     //			if ($user->id == $firstUserInLine->id)
     //			{
     //				// user can start gardening from this point and is removed from waiting list
     //				$user->canStartGardening = Carbon::now();
     //				$user->waitingPosition = null;
     //				$user->save();
     //
     //				// send email to user
     //				//
     //				//
     //			}
     //		}
     // check invitations table to see if this email has outstanding invitations
     $invitations = Invitation::where('email', '=', $user->email)->get();
     foreach ($invitations as $invitation) {
         // link invitations
         $user->plants()->attach($invitation->plant_id);
         // delete record from invitations table
         $invitation->delete();
     }
     Auth::login($user);
     // when user can start gardening set message
     //
     //
     // flash message
     session()->flash('successMessage', 'Hey there, enjoy your stay!');
     return redirect()->route('dashboard');
 }
 /**
  * User list processed by users
  *
  * @return \Illuminate\Http\Response
  */
 public function request_management_resource_list_by_users()
 {
     $requests = Invitation::where('status', 2)->orWhere('status', 3)->paginate(25);
     return $requests;
     // return Response::json([
     // 	'status'=>true,
     // 	'message'=>'Request lists',
     // 	'data'=>$requests
     // ]);
 }
Beispiel #7
0
 public function delete($code)
 {
     $temp = Invitation::where('code', '=', $code)->delete();
 }
Beispiel #8
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $user = $this->create($request->all());
     Auth::login($user);
     if ($request->has('t')) {
         $invitation = Invitation::where(['token' => $request->input('t')])->first();
         if ($invitation) {
             Role::create(['user_id' => $user->id, 'organization_id' => $invitation->organization_id, 'role' => 'admin']);
             $invitation->delete();
         }
     }
     return redirect($this->redirectPath());
 }
Beispiel #9
0
 public function join_external(Request $request, $token)
 {
     $inv = Invitation::where('token', '=', $token)->firstOrFail();
     $part = Participant::findOrFail($inv->participant);
     $room = Room::findOrFail($inv->room);
     if ($part->moderator) {
         $pass = $room->mod_pass;
     } else {
         $pass = $room->att_pass;
     }
     //check if meeting running and create if needed
     $bbb_id = bbbController::running($room);
     if (!$bbb_id) {
         $bbb_id = bbbController::create($room);
     }
     //join meeting
     $bbb = new BigBlueButton($bbb_id);
     $params = array('meetingId' => $room->bbb_meeting_id, 'username' => $part->mail, 'userId' => '', 'webVoiceConf' => '', 'password' => $pass);
     try {
         $result = $bbb->getJoinMeetingURL($params);
     } catch (Exception $e) {
         throw new Exception($e->getMessage() . "\n");
     }
     return redirect($result);
 }