Send a verification email to the user provided (if verification
emails are enabled and account is not already verified)

@param SS_HTTPRequest $request Current request

@return HTMLText
334858
public function sendverification(SS_HTTPRequest $request)
    {
        // If we don't allow verification emails, return an error
        if (!Users::config()->send_verification_email) {
            return $this->httpError(400);
        }

        $sent = false;

        if (Member::currentUserID()) {
            $member = Member::currentUser();
        } else {
            $member = Member::get()->byID($this->getRequest()->param("ID"));
        }

        if ($member && !$member->isVerified()) {
            $sent = $this->send_verification_email($member);
        }

        $this->customise(
            array(
            "Title" => _t('Users.AccountVerification', 'Account Verification'),
            "MetaTitle" => _t('Users.AccountVerification', 'Account Verification'),
            "Content" => $this->renderWith(
                "UsersSendVerificationContent",
                array("Sent" => $sent)
            ),
            "Sent" => $sent
            )
        );

        $this->extend("updateSendVerificationAction");

        return $this->renderWith(
            array(
            "Users_Register_sendverification",
            "Users",
            "Page"
            )
        );
    }
724171
public function postResend(Request $request)
    {
        // Validate the form data
        $result = $this->validate($request, [
            'email' => 'required|email|max:255'
        ]);

        // Fetch the user in question
        $user = Sentinel::findUserByCredentials(['email' => $request->get('email')]);

        // Only send them an email if they have a valid, inactive account
        if (!Activation::completed($user)) {
            // Generate a new code
            $activation = Activation::create($user);

            // Send the email
            $code = $activation->getCode();
            $email = $user->email;
            Mail::to($email)->queue(new CentaurWelcomeEmail($email, $code, 'Account Activation Instructions'));
        }

        $message = 'New instructions will be sent to that email address if it is associated with a inactive account.';

        if ($request->expectsJson()) {
            return response()->json(['message' => $message], 200);
        }

        Session::flash('success', $message);
        return redirect('/dashboard');
    }
924427
public function register(Request $request)
    {
        $data = $request->all();
        $validator = Validator::make($data, [
            'firstname'      => 'required|max:255',
            'surname'        => 'required|max:255',
            'email'          => 'required|email|max:255|unique:users',
            'mobile_number'  => 'required|min:10|unique:signup_data',
            'password'       => 'required|min:6',
            'gender'         => 'required'
        ]);

        if (!empty($validator->errors()->messages())) {
            return new Response([
                'accountRegistered' => 0,
                'status'  => 'FAIL',
                'message' => 'Fail to save user',
                'Errors'  =>  $validator->errors()
            ], 500);
        } else {
            try {
                $this->guard()->login($this->create($data));
                $user = new User();
                $collection = $user->all();
                $userId = $collection->last()->id;
                $this->createSignup($data, $userId);

                if ( config('FHIRConfig.send_signup_notification') == 1 ) {
                    try {
                        Mail::raw( config( 'FHIRConfig.signup_message_body' ), function ( $message ) use ( $data ) {
                            $message->subject( config( 'FHIRConfig.signup_message_subject' ) );
                            $message->from( config( 'FHIRConfig.email_from_address' ) );
                            $message->to( $data[ 'email' ] );
                        } );
                    } catch ( Exception $e ) {
                        error_log( $e->getMessage() );
                    }

                    $sms = new OxygenSms();
                    $sms->send( config( 'FHIRConfig.signup_message_body' ), $data[ 'mobile_number' ] );
                }

                return new Response([
                    'accountRegistered' => 1,
                    'status' => 'OK',
                    'message' => 'User signup data saved',
                ], 201);
            } catch (\Illuminate\Database\QueryException $ex) {
                return new Response([
                    'accountRegistered' => 0,
                    'status'  => 'Fail',
                    'message' => 'Fail saving singup data',
                    'Errors ' =>  $ex->getMessage()
                ]);

            }
        }
    }
577067
public function basic($field = 'email', Request $request = null)
    {
        if ($this->check()) {
            return;
        }

        $request = $request ?: $this->getRequest();

        // If a username is set on the HTTP basic request, we will return out without
        // interrupting the request lifecycle. Otherwise, we'll need to generate a
        // request indicating that the given credentials were invalid for login.
        if ($this->attemptBasic($request, $field)) {
            return;
        }

        return $this->getBasicResponse();
    }
241690
public function createsnapshot(SS_HTTPRequest $request) {
		// Performs canView permission check by limiting visible projects
		$project = $this->getCurrentProject();
		if(!$project) {
			return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404);
		}

		if(!$project->canBackup()) {
			return new SS_HTTPResponse("Not allowed to create snapshots on any environments", 401);
		}

		return $this->customise(array(
			'Title' => 'Create Data Snapshot',
			'Project' => $project,
			'CurrentProject' => $project,
			'SnapshotsSection' => 1,
			'DataTransferForm' => $this->getDataTransferForm($request)
		))->renderWith(array('DNRoot_createsnapshot', 'DNRoot'));
	}
1232222
public function update(Request $request)
    {
        $user = $request->user();

        $this->validate($request, [
            'name' => 'required',
            'email' => 'required|email|unique:users,email,'.$user->id,
        ]);

        return tap($user)->update($request->only('name', 'email'));
    }
1084588
public function getDeployForm(SS_HTTPRequest $request) {
		// Performs canView permission check by limiting visible projects
		$project = $this->getCurrentProject();
		if(!$project) {
			return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404);
		}

		// Performs canView permission check by limiting visible projects
		$environment = $this->getCurrentEnvironment($project);
		if(!$environment) {
			return new SS_HTTPResponse("Environment '" . Convert::raw2xml($request->latestParam('Environment')) . "' not found.", 404);
		}

		if(!$environment->canDeploy()) {
			return new SS_HTTPResponse("Not allowed to deploy", 401);
		}

		if(!$project->repoExists()) {
			$literalField = new LiteralField('noRepoWarning', '<strong>The GIT repository is for the time being not available.</strong>');
			return Form::create($this, 'DeployForm', new FieldList($literalField), new FieldList());
		}

		// Generate the form
		$form = new DeployForm($this, 'DeployForm', $environment, $project);

		// Tweak the action so it plays well with our fake URL structure.
		$form->setFormAction($request->getURL().'/DeployForm');
		return $form;
	}
391082
public function sendEmailAction(Request $request)
    {
        $username = $request->request->get('username');

        /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
        $userManager = $this->get('fos_user.user_manager');

        $user = $userManager->findUserByUsernameOrEmail($username);

        $ttl = $this->container->getParameter('fos_user.resetting.retry_ttl');

        if (null !== $user && !$user->isPasswordRequestNonExpired($ttl)) {
            if (!$user->isAccountNonLocked()) {
                return new RedirectResponse($this->get('router')->generate('networking_init_cms_admin_resetting_request'));
            }

            if (null === $user->getConfirmationToken()) {
                /** @var $tokenGenerator TokenGeneratorInterface */
                $tokenGenerator = $this->get('fos_user.util.token_generator');
                $user->setConfirmationToken($tokenGenerator->generateToken());
            }

            $this->sendResettingEmailMessage($user);
            $user->setPasswordRequestedAt(new \DateTime());
            $userManager->updateUser($user);
        }

        return new RedirectResponse($this->generateUrl('networking_init_cms_admin_resetting_check_email', [
            'username' => $username,
        ]));
    }
354189
public function confirm(HTTPRequest $request)
    {
        if ($this->EmailType !== 'Confirmation' &&
            $this->EmailType !== 'Validation') {
            return $this->httpError(400, 'No confirmation required.');
        }

        $currentMember = Member::currentUser();
        $id = (int)$request->param('ID');
        $key = $request->getVar('key');

        if ($currentMember) {
            if ($currentMember->ID == $id) {
                return Security::permissionFailure($this, _t(
                    'MemberProfiles.ALREADYCONFIRMED',
                    'Your account is already confirmed.'
                ));
            }
            return Security::permissionFailure($this, _t(
                'MemberProfiles.CANNOTCONFIRMLOGGEDIN',
                'You cannot confirm account while you are logged in.'
            ));
        }

        if (!$id ||
            !$key) {
            return $this->httpError(404);
        }

        $confirmationTitle = $this->data()->dbObject('ConfirmationTitle');

        /**
         * @var Member|null $member
         */
        $member = DataObject::get_by_id(Member::class, $id);
        if (!$member) {
            return $this->invalidRequest('Member #'.$id.' does not exist.');
        }
        if (!$member->NeedsValidation) {
            // NOTE(Jake): 2018-05-03
            //
            // You might be hitting this if you set your MemberProfilePage to use
            // Email Setting 'Confirmation' rather than 'Validation' and you didn't
            // edit the original Email template to not include the copy about confirmation.
            //
            return $this->invalidRequest('Member #'.$id.' does not need validation.');
        }
        if (!$member->ValidationKey) {
            return $this->invalidRequest('Member #'.$id.' does not have a validation key.');
        }
        if ($member->ValidationKey !== $key) {
            return $this->invalidRequest('Validation key does not match.');
        }

        // Allow member to login
        $member->NeedsValidation = false;
        $member->ValidationKey = null;

        $validationResult = $member->validateCanLogin();
        if (!$validationResult->isValid()) {
            $this->getResponse()->setStatusCode(500);
            $validationMessages = $validationResult->getMessages();
            return [
                'Title'   => $confirmationTitle,
                'Content' => $validationMessages ? $validationMessages[0]['message'] : _t('MemberProfiles.ERRORCONFIRMATION', 'An unexpected error occurred.'),
            ];
        }
        $member->write();

        $this->extend('onConfirm', $member);

        if ($member->canLogin()) {
            Injector::inst()->get(IdentityStore::class)->logIn($member);
        } else {
            throw new Exception('Permission issue occurred. Was the "$member->validateCanLogin" check above this code block removed?');
        }

        return [
            'Title'   => $this->data()->dbObject('ConfirmationTitle'),
            'Content' => $this->data()->dbObject('ConfirmationContent')
        ];
    }
758985
public void verifyEmail(VerifyEmailRequest request) {
        checkNotNull(request, "object request should not be null.");
        assertStringNotNullOrEmpty(request.getEmailAddress(), "object emailAddress should not be null or empty");

        InternalRequest internalRequest =
                this.createRequest("verifiedEmail", request, HttpMethodName.PUT, request.getEmailAddress());

        this.invokeHttpClient(internalRequest, SesResponse.class);
    }
1013862
public function handleDelete(SS_HTTPRequest $request)
    {
        if (!$this->file->canDelete()) {
            return $this->httpError(403);
        }

        $this->file->delete();

        return new SS_HTTPResponse('OK');
    }
234596
public function registrationSave(ServerRequestInterface $request): ResponseInterface
    {
        Site::setPreference('WELCOME_TEXT_AUTH_MODE', $request->get('WELCOME_TEXT_AUTH_MODE'));
        Site::setPreference('WELCOME_TEXT_AUTH_MODE_' . WT_LOCALE, $request->get('WELCOME_TEXT_AUTH_MODE_4'));
        Site::setPreference('USE_REGISTRATION_MODULE', (string) (bool) $request->get('USE_REGISTRATION_MODULE'));
        Site::setPreference('SHOW_REGISTER_CAUTION', (string) (bool) $request->get('SHOW_REGISTER_CAUTION'));

        FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
        $url = route('admin-control-panel');

        return redirect($url);
    }
1148175
public function authenticate(Request $request)
    {
        return $request->get('username') === $this->username
            && password_verify($request->get('password'), $this->password);
    }
619872
public function toResponse($request): JsonResponse
    {
        return response()->json([
            'success' => $this->result,
            'message' => ($this->result)
                ? trans('comments::messages.send_success')
                : trans('comments::messages.send_fail'),
        ]);
    }
161334
public function messagesSendAction(Request $request)
    {
        $query = $request->request->all();
        $messages = $this->om->findList('Claroline\PlannedNotificationBundle\Entity\Message', 'uuid', $query['messages']);
        $users = $this->om->findList('Claroline\CoreBundle\Entity\User', 'uuid', $query['users']);
        $this->manager->sendMessages($messages, $users);

        return new JsonResponse('success', 200);
    }
959202
public function hipchat(Request $request)
    {
        $this->validate($request, [
            'hipchattoken' => 'required|string|min:1|max:80',
            'roomid' => 'required|string|min:4|max:7',
            'low' => 'required|boolean',
            'medium' => 'required|boolean',
            'high' => 'required|boolean',
        ]);

        Recipient::create([
            'type' => 'hipchat',
            'address' => $request->roomid,
            'meta' => ['token' => $request->hipchattoken],
            'low' => $request->low,
            'medium' => $request->medium,
            'high' => $request->high,
        ]);

        return redirect(route('eyewitness.settings.index').'#recipients')->withSuccess('The HipChat recipient has been created. You can send a test notification to ensure it is working by click on the button next to the recipient.');
    }
376852
public function send(PhoneVerificationSendRequest $request)
    {
        $user = $request->user($this->getGuard())
                ?? $request->attemptUser($this->getGuard())
                   ?? app('cortex.auth.member')->whereNotNull('phone')->where('phone', $request->input('phone'))->first();

        $user->sendPhoneVerificationNotification($request->get('method'), true);

        return intend([
            'url' => route('frontarea.verification.phone.verify', ['phone' => $user->phone]),
            'with' => ['success' => trans('cortex/auth::messages.verification.phone.sent')],
        ]);
    }