Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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();
     }
 }
Ejemplo n.º 3
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();
     }
 }
Ejemplo n.º 4
0
 public function sendInvite(Request $request, $id)
 {
     $organization = Organization::findOrFail($id);
     $email = $request->input('email');
     $user = User::where('email', $request->input('email'))->first();
     if ($user) {
         Role::create(['user_id' => $user->id, 'organization_id' => $organization->id, 'role' => 'admin']);
         $link = url('/') . '/dashboard';
         Mail::send('emails.new_invitation', ['link' => $link], function ($message) use($email) {
             $message->to($email)->subject('You have been invited to Lunch.run!');
         });
         return redirect()->route('organizationUsers', $organization)->with('status', 'The user has been added to your organization.');
     } else {
         $token = substr(md5(rand()), 0, 20);
         Invitation::create(['email' => $email, 'token' => $token, 'organization_id' => $id]);
         $link = url('/') . '/auth/register?t=' . $token;
         Mail::send('emails.new_invitation', ['link' => $link], function ($message) use($email) {
             $message->to($email)->subject('You have been invited to Lunch.run!');
         });
         return redirect()->route('organizationUsers', $organization)->with('status', 'The user has been invited to your organization.');
     }
 }
 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');
 }
Ejemplo n.º 6
0
 /**
  * Detach an invitation from an account
  * @param  \Illuminate\Http\Request $request
  * @param  string $accountId Account primary key
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postDetachInvitation(Request $request, $accountId)
 {
     $account = Auth::user()->accounts()->findOrFail($accountId);
     $invitation = Invitation::find($request->input('invitation_id'));
     $invitation->delete();
     return redirect()->action('Account\\ConfigurationController@getUsers', $account);
 }
 protected function addInvitationToProject(Request $request, $id)
 {
     $array = Input::all();
     $validator = Validator::make($array, ['firstname' => 'required|min:2|max:25', 'lastname' => 'required|min:2|max:50', 'email' => 'required|email|unique:users|unique:invitations', 'type' => 'required|min:1|max:1']);
     if ($validator->fails() || $request->input('type') < 0 || $request->input('type') > 2) {
         return Response::json('validation failed.', 400);
     } else {
         $invitation = new Invitation();
         $urlcode = str_random(40);
         $invitation->urlcode = $urlcode;
         $invitation->firstname = $request->input('firstname');
         $invitation->lastname = $request->input('lastname');
         $invitation->email = $request->input('email');
         $invitation->type = $request->input('type');
         $invitation->owner = $id;
         $invitation->save();
         $data = array('firstname' => $request->input('firstname'), 'lastname' => $request->input('lastname'), 'urlcode' => $urlcode);
         //$mail = $request->input('email'); uncomment for production
         $mail = "*****@*****.**";
         Mail::send('emails.test', $data, function ($message) use($mail) {
             $message->to($mail)->subject('You got invited to Pdmsys! Check it out!');
         });
         return Response::json($invitation);
     }
 }
Ejemplo n.º 8
0
 /**
  * Handles users request registration page.
  *
  * @return \Illuminate\Http\Response
  */
 public function request_sign_up()
 {
     $name = Input::get('name');
     $email = Input::get('email');
     $validate = Validator::make(['name' => $name, 'email' => $email], ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:invite,email'], ['required' => 'El campo :attribute es requerido', 'email' => 'Dirección de correo inválido', 'unique' => 'Este correo ya está registrado']);
     if ($validate->fails()) {
         return Response::json(['status' => false, 'message' => $validate->errors()->all()]);
     }
     $invitation = Invitation::create(['name' => $name, 'email' => $email, 'token' => str_random(15), 'status' => 1]);
     if ($invitation) {
         /* EMAIL NOTICE THE ADMIN */
         //
         //
         //
         /* END EMAIL */
         return Response::json(['status' => true, 'message' => 'Datos enviados correctamente!', 'invitation' => $invitation]);
     } else {
         return Response::json(['status' => false, 'message' => ['Algo ha ocurrido, vuelve a intentarlo.']]);
     }
 }
Ejemplo n.º 9
0
 /**
  * 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
     // ]);
 }
Ejemplo n.º 10
0
 /**
  *
  */
 public function index()
 {
     // 		$invitate = Invitation::find(1);
     $rs = Invitation::incoming(session('rak_tea.uid'));
     return view("teabreak/index/index");
 }
Ejemplo n.º 11
0
 public function delete($code)
 {
     $temp = Invitation::where('code', '=', $code)->delete();
 }
Ejemplo n.º 12
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());
 }
Ejemplo n.º 13
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);
 }
Ejemplo n.º 14
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Invitation::create(['account_id' => 1, 'email' => '*****@*****.**']);
 }