/**
  * Perform the registration.
  *
  * @param  Request   $request
  * @param  AppMailer $mailer
  * @return \Redirect
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $this->validate($request, ['name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required']);
     //$user = User::create($request->all());
     /*$user_data = [
                 'name' => $request->get('name'),
                 'email' => $request->get('email'),
                 'password' => Hash::make($request->get('password')),
                 'token' => 'abc'//$confirmation_code
             ];
     
             print_r($user_data);
             die();*/
     $confirmation_code = str_random(30);
     /*$user = User::create([
           'name' => $request->get('name'),
           'email' => $request->get('email'),
           'password' => Hash::make($request->get('password')),
           'token' => 'abc'//$confirmation_code
       ]);*/
     $user = new User();
     $user->name = $request->get('name');
     $user->email = $request->get('email');
     $user->password = Hash::make($request->get('password'));
     $user->token = $confirmation_code;
     $user->save();
     $user_data = ['name' => $request->get('name'), 'email' => $request->get('email'), 'password' => Hash::make($request->get('password')), 'token' => $confirmation_code];
     $mailer->sendEmailConfirmationTo($user_data);
     // Session::flash('Please confirm your email address.');
     //  flash('Please confirm your email address.');
     Session::put('success', 'Please confirm your email address. ');
     //return redirect()->back();
     return redirect('/pages/confirmMail');
 }
Ejemplo n.º 2
0
 /**
  * Send an email to the user to request his confirmation for being a member of the team
  *
  * @return \Illuminate\Http\Response
  */
 public function sendrequest($plan_id, $id, AppMailer $mailer)
 {
     // check access rights
     if (!Auth::user()->ownsPlan($plan_id)) {
         return redirect('home')->with('error', 'You are unauthorized for this request.');
     }
     // get the resource handle
     $team = Team::find($id);
     if ($team) {
         if ($team->requested) {
             $error = 'Request Email was already sent to this user!';
             return \Redirect::back()->with(['error' => $error]);
         }
         $team->requested = True;
         $team->remember_token = str_random(32);
         // send internal message to user
         $message = 'Please open <a href="' . url('cspot/plans/' . $plan_id) . '/team"> this plan </a> and confirm if you accept the given role.';
         $thread_id = sendInternalMessage('You have been assigned a role in a Service plan', $message, $team->user_id, false);
         $team->thread_id = $thread_id;
         $team->save();
         // also send an email to the user
         $recipient = User::find($team->user_id);
         $plan = Plan::find($team->plan_id);
         $mailer->getPlanMemberConfirmation($recipient, $plan, $team);
         $status = 'Email with membership request was sent to user.';
         return \Redirect::route('team.index', ['plan_id' => $plan_id])->with(['status' => $status]);
     }
     $error = 'Wrong team member id!';
     return \Redirect::back()->with(['error' => $error]);
 }
 public function postRegister(RegistrationRequest $request, AppMailer $mailer)
 {
     $user = User::create($request->all());
     $mailer->sendEmailConfirmationTo($user);
     session()->flash('message', 'Please confirm your email address.');
     return redirect()->back();
 }
Ejemplo n.º 4
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
     $mailer = new AppMailer();
     $mailer->sendEmailConfirmationTo($user);
     return $user;
 }
Ejemplo n.º 5
0
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $input = $request->all();
     $user = User::create($input);
     $mailer->sendEmailConfirmationTo($user);
     session()->flash('message', 'Please Confirm Your Email Address');
     return redirect()->back();
 }
 public function PostRegister(Request $request, AppMailer $mailer)
 {
     $this->validate($request, ['name' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed']);
     $user = User::create($request->all());
     $mailer->sendEmailConfirmationTo($user);
     flash('Please confirm your email address.');
     return redirect()->back();
 }
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $this->validate($request, ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
     $user = User::create($request->all());
     $mailer->sendEmailConfirmationTo($user);
     flash()->message('Please confirm your email address');
     return redirect()->back();
 }
Ejemplo n.º 8
0
 /**
  * Get a validator for an incoming registration request.
  *
  * @param Request   $request
  * @param AppMailer $mailer
  * @param  array    $data
  *
  * @return \Illuminate\Contracts\Validation\Validator
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $this->validate($request, ['firstName' => 'required|max:100', 'lastName' => 'required|max:100', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
     $user = User::create($request->all());
     $mailer->sendEmailConfirmationTo($user);
     $message = trans('messages.please_confirm_email_address');
     flash($message);
     return redirect()->back();
 }
 /**
  * Create user registration.
  *
  * @param Request $request
  * @param AppMailer $mailer
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $this->validate($request, $this->validateRegistrationForm());
     $user = $this->users->create($request->all());
     if (Auth::attempt($this->getCredentials($request))) {
         $mailer->sendEmailVerificationTo($user);
     }
     return redirect('/');
 }
 /**
  * Perform the registration.
  *
  * @param  Request   $request
  * @param  AppMailer $mailer
  * @return \Redirect
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $this->validate($request, ['name' => 'required|alpha_dash', 'email' => 'required|email|unique:users', 'password' => 'required']);
     $password = $request['password'];
     $request['password'] = bcrypt($password);
     $user = User::create($request->all());
     $mailer->sendEmailConfirmationTo($user);
     flash('Please confirm your email address.');
     return redirect()->back();
 }
Ejemplo n.º 11
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $user = $this->create($request->all());
     $mailer->sendEmailConfirmationTo($user);
     flash('Thanks for signing up! Please confirm your email address.');
     return redirect()->back();
 }
Ejemplo n.º 12
0
 /**
  * Deny a user's registration
  *
  * @param  string $token
  * @return mixed
  */
 public function denyRegistration($token, AppMailer $mailer)
 {
     $user = $this->users->denyUser($token);
     if (!empty($user)) {
         $person = new Person();
         $person->setNode($user);
         // Send an email to the user that his email has been confirmed
         $mailer->sendRegistrationDenial($person);
     }
     return redirect('/persons');
 }
Ejemplo n.º 13
0
 public function updateAccount(UpdateAccountRequest $request, AppMailer $mailer)
 {
     $input = $request->all();
     $user = \Auth::user();
     $user->name = $input['name'];
     $user->password = $input['password'];
     $user->save();
     session()->flash("message", "Account Updated. Go ahead and create Reports!");
     $mailer->sendAccountUpdatedNotification($user);
     return redirect("/dashboard");
 }
 /**
  * @param Request $request
  * @param AppMailer $mailer
  * @return mixed
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $page = 'Registratie';
     // Validate the request & create new validator
     $this->validate($request, ['firstname' => 'required|string', 'lastname' => 'required|string', 'phonenumber' => 'required', 'zip' => 'required|string', 'streetnumber' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required|min:6|confirmed', 'password_confirmation' => 'required|min:6']);
     // create the user
     $user = User::create($request->all());
     // email a confirmation link
     $mailer->sendEmailConfirmationTo($user);
     // redirect to confirmation page
     return Redirect::to('register/confirm')->with('user', $user);
 }
Ejemplo n.º 15
0
 public function sendContactMessage(Request $request, AppMailer $mailer)
 {
     // Validate request.
     $this->validate($request, ['name' => 'required|max:255', 'email' => 'required|email|max:255', 'message' => 'required']);
     // Send message.
     $mailer->sendContactMessage($request);
     // Send message has been recieved.
     $mailer->sendRecievedContactMessage($request);
     // Flash message.
     session()->flash('message', 'Your message has been sent!  We will get back to you as soon as possible.');
     // Redirect back.
     return redirect('contact');
 }
Ejemplo n.º 16
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     //Auth::login($this->create($request->all()));
     $user = $this->create($request->all());
     $mailer->sendEmailConfimationTo($user);
     session()->flash('message', 'please confirm your mail address');
     //return redirect($this->redirectPath());
     return redirect()->back();
 }
Ejemplo n.º 17
0
 /**
  * Send a reset link to the given user.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function sendResetLinkEmail(Request $request, AppMailer $mailer)
 {
     $this->validate($request, ['email' => 'required|email']);
     $email = $request->input('email');
     // Check if the given user exists
     $userNode = $this->users->getUser($email);
     if (empty($userNode)) {
         return redirect()->back()->withErrors(['email' => 'Het email adres werd niet gevonden.']);
     }
     $person = new Person();
     $person->setNode($userNode);
     $person->setPasswordResetToken($this->getToken());
     // Send the reset link to the user
     $mailer->sendResetLinkEmail($person);
     return redirect()->back()->with('message', 'Er werd een email verstuurd, hou zeker ook uw SPAM folder in het oog.');
 }
Ejemplo n.º 18
0
 public function update($userId, UpdateUserRequest $request, AppMailer $mailer)
 {
     // Get the user
     $userNode = $this->users->getById($userId);
     if (!empty($userNode)) {
         $person = new Person();
         $person->setNode($userNode);
         $person->update($request->input());
         if ($request->input('verified', false)) {
             // Send an email to the user that his email has been confirmed
             $mailer->sendRegistrationConfirmation($person);
         }
         return response()->json(['message' => 'De gebruiker werd bijgewerkt.']);
     }
     abort(404);
 }
Ejemplo n.º 19
0
 /**
  *
  * Handle a registration request for the application.
  *
  *
  * @param Request $request
  * @param AppMailer $mailer
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function postRegister(Request $request, AppMailer $mailer)
 {
     $validator = $this->registrar->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     // <========= Need to vanish cache if you have, or force user to logout
     // create the user
     $user = User::create($request->all());
     // email them a confirmation link
     $mailer->sendEmailConfirmationTo($user);
     // flash message
     flash('Please confirm your email address');
     // redirect to
     return redirect('auth/login');
 }
Ejemplo n.º 20
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $notifications = QueryHelper::getNotificationsToSend();
     if (count($notifications > 0)) {
         foreach ($notifications as $notification) {
             $user = \App\User::find($notification->user_id);
             $group = \App\Group::find($notification->group_id);
             if ($user && $group) {
                 $this->info('Checking if there is something to send to user:'******' (' . $user->email . ')' . ' for group:' . $group->id . ' (' . $group->name . ')');
                 $mailer = new AppMailer();
                 if ($mailer->sendNotificationEmail($group, $user)) {
                     $this->info('Message sent');
                 } else {
                     $this->info('Nothing sent');
                 }
             }
         }
     }
 }
 /**
  * Update the user profile.
  *
  * @param Request $request
  * @param AppMailer $mailer
  * @return \Illuminate\Http\RedirectResponse
  */
 public function updateProfile(Request $request, AppMailer $mailer)
 {
     $userData = $request->all();
     $this->validate($request, ['name' => 'required|max:255', 'nickname' => $userData['nickname'] != $this->user->nickname ? 'max:255|unique:users' : '', 'email' => $userData['email'] != $this->user->email ? 'required|email|max:255|unique:users' : '']);
     if ($userData['email'] != $this->user->email) {
         $this->user->email = $userData['email'];
         $this->user->token = str_random(30);
         $this->user->is_verified = false;
     }
     $this->user->name = $userData['name'];
     $this->user->nickname = $userData['nickname'];
     $this->user->save();
     if (!$this->user->is_verified) {
         $mailer->sendEmailVerificationTo($this->user);
         flash()->overlay("Profile updated", "Email verification link has been sent to your email address.\\nPlease check your inbox and click on the link.", "success");
     } else {
         flash()->success("Success", "Your profile was successfully updated.");
     }
     return redirect()->back();
 }
Ejemplo n.º 22
0
 /**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request, AppMailer $mailer)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $user = $this->create($request->all());
     $mailer->sendEmailVerificationTo($user);
     \Notification::success(trans('registration.please_verify_email'));
     return redirect('/');
 }
 /**
  * @param Request $request
  * @param AppMailer $mailer
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  *
  * It does not work unless you are logged in for now => need to set up the guard in root.php
  *
  */
 public function postResetEmail(Request $request, AppMailer $mailer)
 {
     // validate if it's email or not
     // validate if it's already in the database
     $this->validate($request, ['email' => 'required|email|unique:users']);
     // create a token
     // create a reacord using User class
     // email, token, 'created_at
     $user_id = \Auth::user()->id;
     $email = $request['email'];
     $token = $this->createNewToken();
     $created_at = \Carbon\Carbon::now();
     // CRATE EMAIL RESET MODEL
     $reset_data = new \App\Email_address_reset(compact('user_id', 'email', 'token', 'created_at'));
     \App\Email_address_reset::create($reset_data->toArray());
     // send an email with a link with the token using helper method
     $mailer->sendEmailConfirmationForResettingEmailWith($reset_data);
     // flash the message too
     flash('Sent an Email with a link, please click the link and activate your new email address');
     //redirect to the current page
     return redirect('/reset/email');
 }
Ejemplo n.º 24
0
 public function update(Request $request, AppMailer $mailer)
 {
     $user = Auth::user();
     // Validate request
     $this->validate($request, ['email' => 'required|unique:users,email,' . $user->id, 'tel_no' => 'required_if:type,1|unique:users,tel_no,' . $user->id]);
     $message = 'Your account has been updated!';
     // Email update
     if ($user->email != $request->email) {
         $user->email = $request->email;
         $user->verified = false;
         $user->generateConfirmationLink();
         $mailer->sendEmailConfirmation($user, true);
         $message = $message . ' Please confirm your email.';
     }
     // Phone update
     $user->tel_no = $request->tel_no;
     // Description update
     $user->description = $request->description;
     if ($request->file('image')) {
         //IMAGE STUFF
         //make timestamp and append username for filename
         $timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
         $imageFile = Input::file('image');
         $mime = "." . substr($imageFile->getMimeType(), 6);
         //move file to /public/images/
         $filename = $timestamp . '-' . $user->username;
         $photoData = array('fileName' => $filename, 'mime' => $mime);
         $photo = Photo::create($photoData);
         $imageFile->move(public_path() . '/images/uploads/', $filename . $mime);
         //associate the image with the user
         $user->photo_id = $photo->id;
         $user->photo()->associate($photo);
     }
     $user->save();
     session()->flash('message', $message);
     return Redirect::route('dashboard');
 }
Ejemplo n.º 25
0
 public function register(Request $request, AppMailer $mailer)
 {
     $input = $request->json()->all();
     $validator = $this->validator($input);
     if ($validator->fails()) {
         return response()->json($validator->errors(), 400);
     }
     // Check if the user already exists
     if (!$this->users->userExists($input['email'])) {
         // Rework the input slightly to match the expected graph format
         $input = $this->restructureUserInput($input);
         $user = $this->users->store($input);
         $mailer->sendRegistrationToAdmin($user);
         return response()->json(['message' => 'Uw registratie is doorgevoerd, een admin moet deze echter wel nog goedkeuren. Hou ook uw SPAM folder in uw inbox in de gaten, de bevestiging kan bij sommige daar terecht komen.']);
     } else {
         return response()->json(['email' => ['Een gebruiker met dit email adres is reeds geregistreerd.']], 400);
     }
 }
 public function postRegister(SubscriptionRequest $request, AppMailer $mailer)
 {
     $subscription = Subscription::create($request->all());
     $mailer->sendEmailConfirmationFor($subscription);
     return redirect()->back();
 }
Ejemplo n.º 27
0
 /**
  * Send verification token to a user, again, for example if it's stuck in spam or wathever else event.
  * @param  Request $request
  * @param  Int  $id      User id
  * @return Flash message and returns to homepage
  */
 public function sendVerificationAgain(Request $request, $id)
 {
     $user = \App\User::findOrFail($id);
     if ($user->verified == 0) {
         $mailer = new AppMailer();
         $mailer->sendEmailConfirmationTo($user);
         flash()->info(trans('messages.invitation_sent_again'));
         return redirect()->action('UserController@show', [$user->id]);
     }
 }
 public function closeReport(CloseReportRequest $request, $id, AppMailer $mailer)
 {
     $report = ExpenseReport::findorFail($id)->load('owner', 'users');
     if ($report->expenses()->count() == 0) {
         return redirect()->back()->withErrors('Reports with no expenses cannot be closed. Consider deleting it.');
     }
     if ($report->status == 0) {
         $report->updateStatus(1);
         $mailer->sendReportClosedNotification($report);
     }
     $oweesAndOwed = $report->oweesAndOwed();
     if (!$report->areSettlementsNecessary()) {
         $messageHeader = 'Settlements for: ' . $report->title;
         $messageBody = 'No settlements are necessary! All users have paid the right amount towards expenses.';
         $report->updateStatus(4);
         return view('utilities.displayMessage', compact(['messageHeader', 'messageBody', 'report']));
     }
     $owees = $oweesAndOwed['owees'];
     $oweds = $oweesAndOwed['owed'];
     $settlements = [];
     //If there is only 1 owee or 1 owed, then the settlements are pre-determined
     if (count($owees) == 1 || count($oweds) == 1) {
         foreach ($owees as $owee) {
             foreach ($oweds as $owed) {
                 $settlements['settlementowee' . $owee[1]->id . 'owed' . $owed[1]->id] = count($oweds) == 1 ? $owee[0] * -1 : $owed[0];
             }
         }
         return redirect('/settlements/' . $id . '/add')->with('settlements', $settlements);
     }
     return view('expenseReports.close', compact(['report', 'oweesAndOwed']));
 }
Ejemplo n.º 29
0
 /**
  * Provider used the "callback URL" and now we process the returned information
  */
 public function getSocialHandle(Request $request, $provider, AppMailer $mailer)
 {
     Log::info($request->ip() . ' - getSocialHandle - User gave consent to register using ' . $provider);
     $social = Socialite::driver($provider);
     $user = $social->user();
     $code = Input::get('code');
     if (!$code) {
         return redirect('login')->with('status', 'danger')->with('message', 'You did not share your profile data with c-SPOT.');
     }
     if (!$user->email) {
         return redirect('login')->with('status', 'danger')->with('message', 'You did not share your email with c-SPOT. You need to visit your ' . $provider . ' App Settings and remove c-SPOT, than you can come back here and login again. Or you can create a new account.');
     }
     $socialUser = null;
     //Check is this email present
     $userCheck = User::where('email', '=', $user->email)->first();
     if (!empty($userCheck)) {
         $socialUser = $userCheck;
     } else {
         $sameSocialId = Social::where('social_id', '=', $user->id)->where('provider', '=', $provider)->first();
         if (empty($sameSocialId)) {
             // As there is no combination of this social id and provider,
             // we create a new one
             $newSocialUser = new User();
             // the email address as provided by the service provider
             $newSocialUser->email = $user->email;
             // perhaps the email contains a name?
             $emailName = explode('@', $user->email)[0];
             if (strlen($user->name) < 3) {
                 $user->name = str_replace('.', ' ', $emailName);
             }
             // the name is hopefully a full name with first- and lastname
             $name = explode(' ', $user->name);
             $newSocialUser->first_name = $name[0];
             $newSocialUser->last_name = count($name) > 1 ? $name[1] : $name[0];
             // save the new user
             $newSocialUser->save();
             // Add role
             $role = Role::whereName('user')->first();
             $newSocialUser->assignRole($role);
             // create record in the social table
             $socialData = new Social();
             $socialData->social_id = $user->id;
             $socialData->provider = $provider;
             $newSocialUser->social()->save($socialData);
             $socialUser = $newSocialUser;
         } else {
             //Load this existing social user
             $socialUser = $sameSocialId->user;
         }
     }
     Log::info($request->ip() . ' - getSocialHandle - trying to do social-sign in');
     $mailer->notifyAdmin($socialUser, 'User confirmed via ' . $provider);
     // $this->auth->login($socialUser, true);
     Auth::login($socialUser, true);
     // write last login field in users table
     Auth::user()->update(['last_login' => Carbon::now()]);
     return redirect()->intended($this->redirectPath());
 }
Ejemplo n.º 30
0
 public function sendReminder(Request $request, $id, $user_id, AppMailer $mailer)
 {
     // find the Plan
     $plan = Plan::find($id);
     // get the recipient
     $recipient = User::find($user_id);
     // what is the role of this user in this plan?
     $role = 'not set';
     if (isset($request->role)) {
         $role = $request->role;
     }
     // verify validity of this request
     if ($plan && $plan->isFuture() && Auth::user()->ownsPlan($id)) {
         $mailer->planReminder($recipient, $plan, $role);
         flash('Email sent to ' . $recipient->fullName);
         return redirect()->back();
     }
     flash('Plan not found!');
     return redirect()->back();
 }