Once the expire pop up appears, how does Liferay know the login URL.?
ex.. if the expired page is
'http://localhost:8080/web/2Fsite/2Fmodule'
And F5 is pressed,how does Life ray know that the URL is
'http://localhost:8080/web/guest/home?_58_redirect=%2Fweb%2Fsite%2Fmodule'...
is this Struts action?
Check com.liferay.portal.servlet.MainServlet - processServicePrePrincipalException method:
String currentURL = PortalUtil.getCurrentURL(request);
redirect = HttpUtil.addParameter(redirect, "redirect", currentURL);
Related
I'm testing a simple log in with httpsession, so after i authenticate the user i add a user attribute to the http session :
#ManagedBean
#SessionScoped
public class loginView {
....
public String connect() {
FacesContext context = FacesContext.getCurrentInstance();
if (authenticated) {
context.getExternalContext().getSessionMap().put("user", login);
return "/home/NewFile?faces-redirect=true";
} else {
context.addMessage(null, new FacesMessage("Unknown login, try again"));
login = "";
pwd = "";
return null;
}
}
}
When i call this function from the login view it redirects to NewFile.xhtml as it's supposed to do. And inside the said xhtml i display the "user" attribute using #{user}. So far everything is working fine but when i refresh the page (NewFile.xhtml) or when i redirect to another page and try to display "user" attribute i get null, is this behavior expected ? does refreshing or redirecting creates another httpsession ? or is it just deleting the attribute i added ?
After some research i succeeded in solving my problem, turns out it's just a stupid mistake of my part. so i thought i should leave the answer here instead of deleting the question. So here goes :
After some looking around I have found out that this had to do with the cookies, so i did track the HTTP traffic using chrome's F12 and and it was the server sending new cookies each time I refresh/navigate. And after some more searching and testing i've found out what was causing the session to invalidate, so i was calling a logout function (that invalidates the session) this way : <h:button outcome="view.logout()"/> turns out outcome executes the function before loading the page so i had to change it to <p:commandButton action="view.logout()"/>
My registration page URL like: www.exmpl.com/index.php?route=account/register when I submit after filled all fields then it redirect me to login page but I want to redirect it to thank you page.How can I do this?
This function (in /catalog/controller/account/register.php) is responsible for redirection ($this->response->redirect($this->url->link('account/success'));, to be more precise). Just need to check which page is "thank you" page (I'm not sure right now).
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$customer_id = $this->model_account_customer->addCustomer($this->request->post);
// Clear any previous login attempts for unregistered accounts.
$this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
$this->customer->login($this->request->post['email'], $this->request->post['password']);
unset($this->session->data['guest']);
// Add to activity log
$this->load->model('account/activity');
$activity_data = array(
'customer_id' => $customer_id,
'name' => $this->request->post['firstname'] . ' ' . $this->request->post['lastname']
);
$this->model_account_activity->addActivity('register', $activity_data);
$this->response->redirect($this->url->link('account/success'));
}
I am using Code first method instead of record method. I have login page from which i am moving to next page that is home page.
public HomePage SubmitClick(string userName, string Password)
{
HtmlEdit txtUsername = new HtmlEdit(_browserWindow);
txtUsername.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "txt_empid");
txtUsername.Text = userName;
HtmlEdit txtPassword = new HtmlEdit(_browserWindow);
txtPassword.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "txt_password");
txtPassword.Text = Password;
HtmlInputButton btnSubmit = new HtmlInputButton(_browserWindow);
btnSubmit.SearchProperties.Add(HtmlInputButton.PropertyNames.Id, "btn_submit");
Mouse.Click(btnSubmit);
return new HomePage(_browserWindow);
}
Redirecting is working fine. My question is how to identify if the open page is valid or not.
What i am planning is to check for some controls like button and hyperlinks if they exist then page is valid. Is it a good method.
First give _browserwindow.WaitForControlReady() it will wait till the browserwindow completely loads the page.
Once the page is loaded use Assert to check for the title of the page whether it is the same as expected.
_browserwindow.WaitForControlReady();
WinTabPage nextPage = new WinTabPage(_browserwindow);
Assert.AreEqual("Home Page", nextPage.Name);
Compare the URL of the next Page.If its the URL thats required then the test case passes.
Uri url = BrowserwindowObj.Uri;
This gives the URL of the current browser Page.
I am building module to register customers and after registration i need to redirect the user to home page (default). I cant see a way as in Orchard everything works as content items.
Some of my code from Controller is given below
$ if (!ModelState.IsValid)
return new ShapeResult(this, _services.New.Checkout_Signup(Signup: signup));
var customer = _customerService.CreateCustomer(signup.Email, signup.Password);
customer.FirstName = signup.FirstName;
customer.LastName = signup.LastName;
customer.Title = signup.Title;
_authenticationService.SignIn(customer.User, true);
return Redirect("~/Home Page URL here...");
In Orchard, the home page has an empty string for its alias. It's possible to look up the RouteValueDictionary of an alias by calling the IAliasService.Get() method. Once you have this, you can simply pass it to RedirectToRoute().
So for the home page:
var homepage = _aliasService.Get(String.Empty);
return RedirectToRoute(homepage);
You can see Orchard using this mechanism to check the home page in the AutoroutePartDriver.cs file lines 66 - 72 in version 1.7.2.
I'm trying to submit a drupal 6 form PIA to a third party site for processesing, but after submitting the form, I need to redirect to a thank you page within my own site.
I've read this post - Drupal form submission to a 3rd party website
but i'm nor sure how to set up the redirect properly.
this is my code:
$form_state['#action'] = 'external site.com';
$form['#redirect'] = 'thankyou.com';
thanks
Make sure the redirect is the last step. Something like this:
function my_module_form {
$form['#action'] = 'some.external.site';
# Store the redirect in a value element, maybe we need some data
# which are passed to the form, like a user ID, node ID etc.
# So lets store the link in a value element
$form['redirect_link'] = array(
'#type' => 'value',
'#value' => url('some.redirect.page'),
);
}
function my_module_form_validate ($form, &$form_state) {
# Do some validation stuff...
}
function my_module_form_submit($form, &$form_state) {
# show some confirmation message...
drupal_set_message(t('Successfully sent your data into space.'));
# And finally the redirect...
# The 'redirect_link' value was passed internally, without being sent
# to the browser so we can safely use it.
$form_state['redirect'] = $form_state['values']['redirect_link']
}
Redirect property is also set in $form_state.
$form_state['redirect'] = 'some.com';
Since I'm only trying to send informtaion to a third party and not actually redirecting the page after form submission to a third party site.
I got the right answers tot he wrong question.
This is what I ended up using that worked for me:
$url = 'http://thirdpartyurl';
$headers = array('Content-Type' => 'application/x-www-form-urlencoded');
$data = drupal_query_string_encode($pass_the_form_info);
drupal_http_request($url, $headers, 'POST', $data);