15.13.3. Logging in immediately
The simplest strategy is to simply log the user in immediately. The following navigation rule shows how to handle this using the
#{openid.loginImmediately()}
action.
<page view-id="/openid.xhtml"> <navigation evaluate="#{openid.loginImmediately()}"> <rule if-outcome="true"> <redirect view-id="/main.xhtml"> <message>OpenID login successful...</message> </redirect> </rule> <rule if-outcome="false"> <redirect view-id="/main.xhtml"> <message>OpenID login rejected...</message> </redirect> </rule> </navigation> </page>
The
loginImmediately()
action checks whether the OpenID is valid. If it is valid, an OpenIdPrincipal
is added to the identity component, and the user is marked as logged in (that is, #{identity.loggedIn}
is marked true
), and the loginImmediately()
action returns true
. If the OpenID is not validated, the method returns false
, and the user re-enters the application un-authenticated. If the user's OpenID is valid, it will be accessible using the expression #{openid.validatedId}
and #{openid.valid}
will be true.