public function handleForgot(array $request = [])
    {
        $validator = new \Valitron\Validator($request);
        $validator->rule('required', 'email');
        $validator->rule('email', 'email');
        if ($validator->validate() === false) {
            if (headers_sent() === false) {
                header('X-PHP-Response-Code: 422', true, 422);
            }
            return $this->templates->render("Auth::Forgot", [
                "messages" => [
                    'error' => $validator->errors(),
                    'info' => '',
                    'success' => '',
                    'warning' => ''
                ],
                "email" => $request['email']
            ]);
        }

        $response = $this->core->api('User/forgot/' . $request['email'], 'POST')->run($request);
        if (headers_sent() === false) {
            foreach ($response["headers"] as $header) {
                header($header[0], $header[1], $header[2]);
            }
        }
        if ($response["headers"][0][2] === 422) {
            return $this->templates->render("Auth::Forgot", [
                "messages" => [
                    'error' => $response['response'],
                    'info' => '',
                    'success' => '',
                    'warning' => ''
                ],
                "email" => $request['email']
            ]);
        } elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('login-page') . "?m=2");
            } else {
                return 'Redirect: ' . $this->router->generate('login-page') . "?m=2";
            }
        } else {
            return $this->templates->render("500", [
                "error" => $response['response'],
                "result" => ''
            ]);
        }
    }
public function handleForgot(array $request = [])
    {
        $validator = new \Valitron\Validator($request);
        $validator->rule('required', 'email');
        $validator->rule('email', 'email');
        if ($validator->validate() === false) {
            if (headers_sent() === false) {
                header('X-PHP-Response-Code: 422', true, 422);
            }
            return $this->templates->render("Auth::Forgot", [
                "messages" => [
                    'error' => $validator->errors(),
                    'info' => '',
                    'success' => '',
                    'warning' => ''
                ],
                "email" => $request['email']
            ]);
        }

        $response = $this->core->api('User/forgot/' . $request['email'], 'POST')->run($request);
        if (headers_sent() === false) {
            foreach ($response["headers"] as $header) {
                header($header[0], $header[1], $header[2]);
            }
        }
        if ($response["headers"][0][2] === 422) {
            return $this->templates->render("Auth::Forgot", [
                "messages" => [
                    'error' => $response['response'],
                    'info' => '',
                    'success' => '',
                    'warning' => ''
                ],
                "email" => $request['email']
            ]);
        } elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
            if (isset($_GET['template']) === false) {
                return redirect($this->router->generate('login-page') . "?m=2");
            } else {
                return 'Redirect: ' . $this->router->generate('login-page') . "?m=2";
            }
        } else {
            return $this->templates->render("500", [
                "error" => $response['response'],
                "result" => ''
            ]);
        }
    }
public function handleForgot ( array $ request = [ ] ) { $ validator = new \ Valitron \ Validator ( $ request ) ; $ validator -> rule ( 'required' , 'email' ) ; $ validator -> rule ( 'email' , 'email' ) ; if ( $ validator -> validate ( ) === false ) { if ( headers_sent ( ) === false ) { header ( 'X-PHP-Response-Code: 422' , true , 422 ) ; } return $ this -> templates -> render ( "Auth::Forgot" , [ "messages" => [ 'error' => $ validator -> errors ( ) , 'info' => '' , 'success' => '' , 'warning' => '' ] , "email" => $ request [ 'email' ] ] ) ; } $ response = $ this -> core -> api ( 'User/forgot/' . $ request [ 'email' ] , 'POST' ) -> run ( $ request ) ; if ( headers_sent ( ) === false ) { foreach ( $ response [ "headers" ] as $ header ) { header ( $ header [ 0 ] , $ header [ 1 ] , $ header [ 2 ] ) ; } } if ( $ response [ "headers" ] [ 0 ] [ 2 ] === 422 ) { return $ this -> templates -> render ( "Auth::Forgot" , [ "messages" => [ 'error' => $ response [ 'response' ] , 'info' => '' , 'success' => '' , 'warning' => '' ] , "email" => $ request [ 'email' ] ] ) ; } elseif ( ( $ response [ "headers" ] [ 0 ] [ 2 ] - 200 ) * ( $ response [ "headers" ] [ 0 ] [ 2 ] - 299 ) <= 0 ) { if ( isset ( $ _GET [ 'template' ] ) === false ) { return redirect ( $ this -> router -> generate ( 'login-page' ) . "?m=2" ) ; } else { return 'Redirect: ' . $ this -> router -> generate ( 'login-page' ) . "?m=2" ; } } else { return $ this -> templates -> render ( "500" , [ "error" => $ response [ 'response' ] , "result" => '' ] ) ; } }
Handle the forgot password page submission
Handle the forgot password page submission