Seam redirection with condition based on EL - jboss

I have a seam web application.
During the user navigation I want to above the user to access again to login page, after successfull login.
When user is log-in successfully it is redirected to home.xhtml page.
If (after login) the user type again the url of login page I want to redirect it automatically to home.
I tried with Seam pages.xml:
<page view-id="/common/jsp/login.xhtml">
<navigation>
<rule if="#{myUserBean.isUserAlreadyAuthenticated()} ">
<redirect view-id="/home.xhtml"/>
</rule>
</navigation>
but it doesnt' work. Probably because Seam manual specify:
Rules work by evaluating the return value of the action method; it is
not possible to evaluate an arbitrary EL expression.
But in my case it doesnt'come from any specific action, the user is asking for login page from an already logged session, where he can have alredy did a lot of actions, or also no one.
Do you have any suggestion?

I should have solved in this way:
<page view-id="/common/jsp/login.xhtml" action ="#{myUserBean.isUserAlreadyAuthenticated()}">
<navigation>
<rule if-outcome="true">
<redirect view-id="/home.xhtml"/>
</rule>
</navigation>

Related

Deeplink is only working with custom scheme not HTTPS

I´m currently working with Ionic 5 and trying to add a deeplink functionality for activating and account or resetting a password.
My current solution is working in general but only with my custom scheme but not with HTTPS. Maybe I got something wrong but I want the user to click on an HTTPS link which comes in via mail and open the app instead of the browser with Https. I tested in a codepen and it´s working with myScheme://myurl.com/user/activate?link={linkGuid} but not with https://myurl.com/user/activate?link={linkGuid}.
Here is my config.xml:
<plugin name="ionic-plugin-deeplinks" spec="1.0.24">
<variable name="URL_SCHEME" value="myScheme" />
<variable name="DEEPLINK_SCHEME" value="https" />
<variable name="DEEPLINK_HOST" value="myurl.com" />
</plugin>
Any ideas what I could try to make it work?
Thanks in advance!
Cheers!

How to redirect MVC app action calls to distant web api using IIS url rewrite

I have a website (.net core, compiled all in dlls, i.e. no views, no javascript available to modify) which I don't have the source code (was made by someone else who's no longer reachable) and my client wants a single page on this website that makes an ajax call to an action of a controller in this same app to be redirected to a new web api method.
So, for example, this page (_http://the-old-site.com/Home/Index) have a form with a field and a button. Upon entering some values in the form's field and pressing the button, a POST ajax call is made to _http://the-old-site.com/Home/Process passing the value to the action.
I'm trying to configure the url rewrite module so that instead of calling _http://host.com/Home/Process, it posts to _http://new-api-I-did.com/Process
Right now, my rule looks like this but it's never hit:
<system.webServer>
<rewrite>
<rules>
<rule name="redirect to api" stopProcessing="true">
<match url="/Home/Process" />
<action type="Rewrite" url="http://new-api-I-did.com/Process" />
</rule>
</rules>
</rewrite>
</system.webServer>
The api in itself works perfectly when testing it with Postman.
Everything works except for the rewrite. And I tried both rewriting and redirecting.
Thanks in advance.
EDIT
Got the rule working but now, what's being sent in the redirection is an OPTIONS instead of a POST and the form's data aren't sent... Not sure how I can do this anymore.

How to set up Umbraco to default in a subpage?

I have this question about umbraco structuring and I can't find the answer anywhere.
Typically in Umbraco it will default the root site to the first node of the tree.
so if we have
Home
page 1
page 2
the default page will be home (so www.mysite.com will point to home).
How do I change this however so that www.mysite.com will point to page1 or page2?
What if I have this structure?
wrapper
index
page 1
page 2
and I want www.mysite.com to go straight to www.mysite.com/index.aspx
I couldn't find a rule that does that. Tried inserting a rewrite/redirect rule and it didn't change anything.
Please help
Nick
Redirecting in Umbraco is usually a very simple affair, except when you're trying to redirect from the root node of your site.
Method 1:
It explains it best here : http://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracoredirect
So it's possible by adding a umbracoInternalRedirectId property to your root node, with the data type of Content Picker. Note that it does not redirect the user but instead load the contents of that page inside the current url. So the URL will remain as http://www.mysite.com whilst serving the contents of the page that you want to redirect to.
Method 2:
If you really want it to change from http://www.mysite.com/ to http://www.mysite.com/index.aspx. I usually add something like the following code to the template of the root node.
<%# Master Language="C#" MasterPageFile="~/umbraco/masterpages/default.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">
</asp:Content>
<script type="c#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect("http://www.mysite.com/index.aspx");
}
</script>
So that ASP.Net is responsible for the redirect. But it obviously won't handle node rename/moving too well.
you can redirect to any page using Url Rewriting
Config/UrlRewriting.config
adding this Role
<add name="role1"
virtualUrl="^~/$"
destinationUrl="~/home"
redirect="Application"
redirectMode="Permanent"
ignoreCase="true" />
This will do the trick: add a rewrite rule to the Web.Config -
<rewrite>
<rules>
<rule name="Redirect to front" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/yourViewName" />
</rule>
</rules>
</rewrite>
Just include that inbetween the system.webServer tags within the configuration tags, and replace yourViewName by the appropriate view's name (like Contact or Work) and you're done!
All tested & works like a dream.
Cheers #

Tomcat FORM based authentication, on every page

I would like to use authentication form on every page (in the header of the page), so user could authenticated from any page.
I'm using Tomcat's FORM based authentication, but when i go to my index page, and try to login using the form in the header, I get:
HTTP 400 - Invalid Direct Reference To Login Page
Is there any workaround I could use, some settings in web.xml maybe, to solve this problem?
Edit:
Here is the header's login form:
<form method="post" action="j_security_check">
<input type="text" name="j_username" class="login"/>
<input type="password" name="j_password" class="login"/>
<input type="submit" value="Login"/>
</form>
The concept of Tomcat's form based authentication is that it intercepts unauthenticated requests to protected pages and internally redirects to a separate login page. It also saves the original page request. Once the user has successfully logged in, the original page request is replayed and the protected page is displayed.
What you are trying to achieve is - as far as I can derive from your short description - something different. Basically, all your pages are public. Optionally, a user can log in and will then get personalized pages.
Tomcat won't help you implementing this. When you use the j_security_check action, it will be unable to do anything because it never intercepted a request in the first place.
Instead, it's probably easier to check the username and password yourself if the login form is submitted. If they are okay, just put the username into your session data. An authenticated session can easily be recognized as it contains the username in the session data.
There is probably even a way to reuse the Tomcat realms that are e.g. able to check username and password against a database. But I don't know for sure.
Are you stated your login screen as "welcome" ? In case of success login it tries to loop you through login page again. What is welcome-page tag in your web.xml ?

facebook error The page you requested was not found. - When inviting friends to join

I am a .net developer, using iframe xfbml and asp.net of course.
I am getting the following error:
The page you requested was not found.
You may have clicked an expired link or mistyped the address. Some web addresses are case sensitive.
* Return home
* Go back to the previous page
I am using the request-form tag as following:
<fb:request-form target="_top" action="http://apps.facebook.com/myapp"
method="POST" invite="true" type="myappliation"
content="come see
<fb:req-choice url='http://apps.facebook.com/myapp' label='i am coming' /> " >
<fb:multi-friend-selector rows="3" showborder="false" actiontext="its now shame to ask for help!" max="10" style="height:100px;" target="_top" />
</fb:request-form>
This code is working for some of the users, but for new ones they recieve that error. Why is that happening? How can I fix it?
I'm experiencing the same problem for a while. I tried with 2 applications, same configuration, with inviting the same user, and it's working for one of them but not the other...
By browsing similar post, I found no other solution except using the old API (see this post related) :
Facebook multi-friend-selector + new javascript API = BROKEN?
However, this does not help me since, I need the FB.ui function to pop up a dialog...
Facebook bugs me !