Typo3 Neos Redirect to Backend - typo3

I got question about example site on Typo3 Neos. There is create an account, and i tested it on backend. After submitting, the page return to backend again. But when i try to make a form just like that, the return target is to the route, not to the backend. How can i achieve same return like example?
Even though i already implement same code like example.
$uriBuilder = new UriBuilder();
$uriBuilder->setRequest($this->request->getParentRequest());
$redirectUri = $uriBuilder ->setCreateAbsoluteUri(TRUE)
->uriFor('index', array('username' => $accountIdentifier), 'Login', 'TYPO3.Neos');
$this->redirectToUri($redirectUri);
Edit: I got an error from 'action', the path he's trying to do is "http://domain/Route/Action/", that should be only "Action". Care to explain?
Any help would be much appreciated. :)

got the answer
$this->redirect("youraction");
thanks!

Related

What are some reasons I could be getting a "Forbidden (CSRF cookie not set.)" error when trying to send a delete request?

This is really confusing me because I know I'm setting the csrftoken correctly in the header. When I try and send the delete request on Postman I get the same error. I've been searching for a solution for hours and can't seem to find anything good! Do you know what could possibly be happening?
This is some relevant frontend code
var csrftoken = this.getCookie('csrftoken');
axios.defaults.headers.delete['X-CSRFToken'] = csrftoken
axios.defaults.headers.delete['X-Requested-With'] = 'XMLHttpRequest'
axios
.delete(`http://localhost:8000/api/todos/${item.id}`)
.then(res => this.refreshList());
Let me know if you need anymore info. Any help will be appreciated.
I found the problem. My Delete URL pattern had a slash at the end, and as you can see here, there is no slash after the ID in the axios request. A classic blunder for a coder. I hate small bugs like this, don't you? Still can't help but smile now that it's gone though. I suppose you only learn to check for small things like this with experience. Such is the journey of a young web developer.

Redirect dynamically created subdomains to main page in Laravel 5.3

I am working on multi-tenant approach. I created a new tenant with all its information in database including its sub-domain. My approach is separate database and separate sub-domains for each customer. So, I am creating a sub-domain on button click and saving it in database. Now, I am lost on my way how to redirect that sub-domain to main page. I just need to redirect it to main page nothing else, I will work on separate db connection later. I also created the wildcard subdomain entry from cpanel. I am working on wildcard domains for the first time and also I am on my way of learning laravel.
Here is my code:
routes/web.php
Route::group(array('domain' => '{account}.example.com/tracker'), function()
{
Route::get('/', 'HomeController#index');
});
HomeController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function index()
{
return view('welcome');
}
}
I know there are lot of things missing that's why its not working but I tried many solutions I found on google and stackoverflow but still I am unable to figure out what I am doing wrong. Please help me how to overcome this issue. Also, please if anyone have good tutorial on this topic, please share that with me.
Thank you
I solved my problem by using this solution on stackoverflow.
Allow multiple subdomain in laravel without making subdomain as route variable?
It worked like a charm. Hope it helps someone.
Thank you.

Perl WWW::Mechanize::Firefox POST() Implementation

Can I get some help on how to submit a POST with the necessary variables using WWW::Mechanize::Firefox? I've installed all the perl modules, and the firefox plugin and tested such that I can connect to a give host and get responses... my questions is how to submit a POST request. On the documentation Corion says he may never implement. This seems odd, I'm hoping I can use the inherited nature from Mechanize, but can't find any examples. A simple example would help me tremendously.
my $mech = WWW::Mechanize::Firefox->new();
$mech->allow( javascript =>1); # enable javascript
# http
$mech->get("http://www.example.com");
my $c = $mech->content;
Is there a mech->post() option I am simply missing?
many thanks in advance.
R
Normally you would just set the fields and submit the form like this:
$mech->get('http://www.website.com');
$mech->submit_form(
with_fields => {
user => 'me',
pass => 'secret',
}
);
get a page, fill out a form, submit the form
if you're going to be skipping the above steps by using post, you don't need mechanize firefox

Zend Framework rememberMe() doesnt seem to remember me

My session seems to only be valid in the current window/tab. Also it seems to timeout quickly. Heres how I'm currently attempting to do it:
This is in my login controller:
$adapter = $this->getAuthAdapter($data);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($adapter);
if (!$result->isValid()) {
$this->view->err = "Invalid username or password.<br/>Please try again.";
return $this->render('index'); // re-render the login form
}
Zend_Session::rememberMe(60*60*24*7*4);
And this is in my bootstrap:
Zend_Session::start();
I'm relatively new to some of this stuff, so bear with me! Any help would be greatly appreciated.
Here's what was happening. This website was on a server sharing a sessions folder with another website on the server. Even though I increased session lifetime with ini_set, my sessions were still being deleted by the other application.
To solve this I simply set session.save_path to a new folder. Problem solved!
I just want to add that you change the session.save_path in the .htaccess with the follow row to make it work. I saw the answer thought I changed it in the .ini, but it's in the .htaccess.
For example:
php_value session.save_path /home/kaos/data/sessions/
Looking through the source for zend_session, the rememberMe() method calls rememberUntil() which calls the built in php method session_set_cookie_params()
So you may wish to check your php.ini values for session.cookie_lifetime. If it isn't 0, then Zend_Session::rememberMe() would be useless unless the value is less than session.cookie_lifetime. In which case you would want to set it to 0 in either php.ini or in your application using ini_set() as indicated in the first comment on the session.cookie_lifetime man page.

Can I integrate a Zend-Framework powered web application into a wordpress site?

I have a project in which I want to be able to call wp_list_pages() on a page that also uses the Zend Framework to power some complex interfaces manages custom data outside of wordpress.
This page should also redirect the user to the wordpress login screen if they're not already logged in with the appropriate level of authorization.
How would this work at a high level, i.e. do I need to edit the wordpress bootstrap file to conditionally implement the custom interface based on a specific URL or something, but still include certain files to be able to call wp_list_pages() on that custom interface?
I've developed a couple of WordPress plugins, and I've found it's really easy to extend. Haven't worked with Zend though.
You should check the WordPress plugin api. Mostly the part about actions, filters and hooks: http://codex.wordpress.org/Plugin_API
You can even override some functions (not sure if wp_list_pages() is overridable).
It's pretty well documented, and there's a large developer community behind it on IRC, forums, etc.
Thanks Fernando.
I just read this thread which suggests that you can use Zend in any script by just including:
require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();
So given that all I need to use Zend for is on one page, can I just include that code in a custom template file that I assign to the appropriate page in the navigation? If I used javascript to submit the form via XHR, the requested URL would take the form '/controller/action' - but Zend wouldn't know the controller directory.
Could I put Zend code into the wordpress bootstrap, i.e. the above code plus the frontController configuration, and then use Zend wherever however?
So I've created a page in Wordpress and a custom template for that page, in which I've placed the following Zend Framework code:
require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();
$db = Zend_Db::factory('Pdo_Mysql', array(
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'dbname' => 'dbname'
));
Zend_Db_Table::setDefaultAdapter($db);
class Users extends Zend_Db_Table_Abstract {
protected $_name = 'wp_users';
}
$users = new Users();
$users = $users->fetchAll()->toArray();
print_r($users[0]['user_login']);
This all works fine, so it's clearly possible to use Zend in conjuction with Wordpress at least to some extent.
It's becoming apparant that the problem is about who controls the URL rewriting, or the routing, or the bootstrapping (not sure of the correct terminology). If I were to put the end of the above code, starting $users = new Users();, into a controller as follows:
class UsersController extends Zend_Controller_Action {
function getUserAction() {
$this->_helper->viewRenderer->setNoRender();
$users = new Users();
$users = $users->fetchAll()->toArray();
echo $users[0]['user_login'];
}
}
How would I then call that function? My intention would be to call it from javascript via an XHR request in response to an event on the page, but requesting the URL 'index.php/Users/getUser/' returns 'No input file selected'. Trying to access the URL http://www.domain.com/Users/getUser/ produces a Wordpress 404 page.
Is there a way around this? It doesn't just apply to wordpress, of course - I expect it applies to any existing application that rewrites/routes requests via a bootstrap.
I guess you could do that, just import the framework into the one page you need it for. I don't know how Zend works, but check the paths as to where to put your directories so that Zend finds them.As I said I guess you could do that, just experiment and tell us how it went!
Beware of name conflicts for functions and/or variables, this shouldn't be much of a problem coming from such popular products as WordPress and Zend though... (which should be theoretically well coded)
I guess you could do that, just import the framework into the one page you need it for. I don't know how Zend works, but check the paths as to where to put your directories so that Zend finds them.As I said I guess you could do that, just experiment and tell us how it went!
Beware of name conflicts for functions and/or variables, this shouldn't be much of a problem coming from such popular products as WordPress and Zend though... (which should be theoretically well coded)
I've built a plugin for wordpress that has a similar goal to yours, more modeled on CodeIgniter though. Not knowing Zend terribly well, I think this should help:
Make a file named routes.php in your plugins directory with the following code:
add_action( 'init', 'add_custom_urls' );
function add_custom_urls(){
global $wp, $wp_rewrite;
$wp_rewrite->add_rule( '(.*)$', 'index.php?&cPath=$matches[1]', 'top' );
$wp->add_query_var( 'cPath' );
}
Be sure to activate both plugins in your admin. These two files will allow you to catch the url before Wordpress tries to figure out what to do with it. You can use regular expressions to have finer control over which pages to catch. You may have to delete the record in your _options db table where option_name = 'rewrite_rules' before this works.
Next, make another plugin with the following code:
add_action( 'template_redirect', 'bootstrap' );
function bootstrap(){
global $cPath;
echo( "cPath : $cPath" );
if( $cPath ){
dosomethingwith( $cPath );
}
}
Put all your code in the dosomethingwith() function. You'll need to figure out if the url requested can me mapped to a zend controller, etc. http://www.domain.com/Users/getUser/ would give you $cPath = Users/getUser/ If successful, you'll also probably want to die(), so once it is completed Wordpress won't try and take over again.