src/Synapse/User/ResetPasswordController.php
public function post(Request $request)
    {
        // Validate user
        $email = Arr::get($this->getContentAsArray($request), 'email');
        $user  = $this->userService->findByEmail($email);

        if (! $user) {
            return $this->createNotFoundResponse();
        }

        // If a token exists that won't expire in the next 5 minutes, send it
        $token = $this->userService->findTokenBy([
            'user_id'       => $user->getId(),
            'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD,
            ['expires', '>', time() + 5*60],
        ]);

        // Otherwise create a new token
        if (! $token) {
            $token = $this->userService->createUserToken([
                'user_id'       => $user->getId(),
                'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD,
                'expires'       => strtotime('+1 day', time()),
            ]);
        }

        $this->resetPasswordView->setUserToken($token);

        $email = $this->emailService->createFromArray([
            'recipient_email' => $user->getEmail(),
            'subject'         => 'Reset Your Password',
            'message'         => (string) $this->resetPasswordView,
        ]);

        $this->emailService->enqueueSendEmailJob($email);

        return $this->create204Response(204, '');
    }
public function post(Request $request)
    {
        // Validate user
        $email = Arr::get($this->getContentAsArray($request), 'email');
        $user  = $this->userService->findByEmail($email);

        if (! $user) {
            return $this->createNotFoundResponse();
        }

        // If a token exists that won't expire in the next 5 minutes, send it
        $token = $this->userService->findTokenBy([
            'user_id'       => $user->getId(),
            'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD,
            ['expires', '>', time() + 5*60],
        ]);

        // Otherwise create a new token
        if (! $token) {
            $token = $this->userService->createUserToken([
                'user_id'       => $user->getId(),
                'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD,
                'expires'       => strtotime('+1 day', time()),
            ]);
        }

        $this->resetPasswordView->setUserToken($token);

        $email = $this->emailService->createFromArray([
            'recipient_email' => $user->getEmail(),
            'subject'         => 'Reset Your Password',
            'message'         => (string) $this->resetPasswordView,
        ]);

        $this->emailService->enqueueSendEmailJob($email);

        return $this->create204Response(204, '');
    }
public function post ( Request $ request ) { // Validate user $ email = Arr :: get ( $ this -> getContentAsArray ( $ request ) , 'email' ) ; $ user = $ this -> userService -> findByEmail ( $ email ) ; if ( ! $ user ) { return $ this -> createNotFoundResponse ( ) ; } // If a token exists that won't expire in the next 5 minutes, send it $ token = $ this -> userService -> findTokenBy ( [ 'user_id' => $ user -> getId ( ) , 'token_type_id' => TokenEntity :: TYPE_RESET_PASSWORD , [ 'expires' , '>' , time ( ) + 5 * 60 ] , ] ) ; // Otherwise create a new token if ( ! $ token ) { $ token = $ this -> userService -> createUserToken ( [ 'user_id' => $ user -> getId ( ) , 'token_type_id' => TokenEntity :: TYPE_RESET_PASSWORD , 'expires' => strtotime ( '+1 day' , time ( ) ) , ] ) ; } $ this -> resetPasswordView -> setUserToken ( $ token ) ; $ email = $ this -> emailService -> createFromArray ( [ 'recipient_email' => $ user -> getEmail ( ) , 'subject' => 'Reset Your Password' , 'message' => ( string ) $ this -> resetPasswordView , ] ) ; $ this -> emailService -> enqueueSendEmailJob ( $ email ) ; return $ this -> create204Response ( 204 , '' ) ; }
Send reset password email

@param  Request $request
@return array
Send reset password email