Redirection loggin to specific page

Thibaut Wavreille December 19, 2013

Hi,

I'd loke to make a automatically rediction after the loggin of users to a specfic page (I can defined).

So I found the VM file loggin.vm that I could update but how could I do it ?

Thank you

7 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 6, 2014

What you will do is change the hidden input right before the closing </fieldset> tag:

<input type="hidden" name="os_destination" value="$!generalUtil.escapeXml($!os_destination)"/>

Change it to something like:

<input type="hidden" name="os_destination" value="/display/your/page"/>

This creates the link I was talking about. Sorry, but like I said, there are different places that I use this technique, so I misunderstood exactly what you needed. This should work for you though (I tested it on my Confluence instance).

0 votes
Thibaut Wavreille January 7, 2014

So I found the solution myself.

I'm using : /pages/viewpage.action?pageId=...

0 votes
Thibaut Wavreille January 7, 2014

Ah great ! You're right, thank you a lot.

I updated the line as you told me and perfect !

One last point is :
you're using the title of a page to make the redirection, is it possible to use page id instead of page title ?

Thank you :)

0 votes
Thibaut Wavreille January 6, 2014

So the problem comes from the url when I'm trying to connect :
.../login.action?os_destination=%2Fdisplay%2FHOME%2FHomepage
But I don't find the link to this page in vm files.

So could you help me please ?

The last solution is to use a redirection macro to this page to the correct one.

0 votes
Thibaut Wavreille December 19, 2013

I tried but it doesn't work...

Maybe I need to update another action ...

Here he solved his problem with the same attribute : http://stackoverflow.com/questions/9801352/wrong-redirect-after-login-to-confluence-homepage-in-stead-of-my-app-using-crow

0 votes
Thibaut Wavreille December 19, 2013

Hi Matthew,

So you want to update this row :

&lt;a class="reload" href="${req.contextPath}/dologin.action?os_username=${action.os_username}"

and add at the end :

&lt;a class="reload" href="${req.contextPath}/dologin.action?os_username=${action.os_username}&amp;os_destination=/display/doc/your+page"

Thank you in advance

This is all the code from the file login.vm

#* @vtlvariable name="action" type="com.atlassian.confluence.user.actions.LoginAction" *#
#macro (errorBlock $msg)
&lt;div class="error" tabindex="0"&gt;&lt;p&gt;$msg&lt;/p&gt;&lt;/div&gt;
#end

#set($showSignup = $action.isShowSignUp() &amp;&amp; !$action.isElevatedSecurityCheckRequired())

&lt;html&gt;
	&lt;head&gt;
        #requireResource("confluence.web.resources:master-styles")
        #requireResource("confluence.web.resources:login")
        #requireResource("confluence.web.resources:aui-forms")
	    #if( $fromNotPermitted )
		    &lt;title&gt;$i18n.getText("title.not.permitted")&lt;/title&gt;
	    #else
		    &lt;title&gt;$action.getActionName($action.getClass().getName())&lt;/title&gt;
		    &lt;content tag="pageTitle"&gt;&lt;a href="${req.contextPath}/homepage.action"&gt;$action.globalSettings.siteTitle&lt;/a&gt;&lt;/content&gt;
		#end
	&lt;/head&gt;
	&lt;body&gt;
		
        &lt;content tag="bodyClass"&gt;login&lt;/content&gt;
		#if($showSignup)
		#requireResource("confluence.web.resources:signup")
		&lt;script&gt;
			AJS.$('#com-atlassian-confluence.login h1').addClass('unified-header');
		&lt;/script&gt;
		#end

        &lt;div id="login-container" #if($showSignup)class="unified-container"#end&gt;
        #if ($remoteUser)
            &lt;div class="login-section"&gt;
                &lt;h2&gt;$action.getText('login.name')&lt;/h2&gt;
                #parse ('/template/includes/actionerrors.vm')
                &lt;p&gt;$i18n.getText('login.logged.in', $remoteUser.name)&lt;/p&gt;
                &lt;p class="last"&gt;$i18n.getText('login.logged.in.description')&lt;/p&gt;
            &lt;/div&gt;
        #else
			&lt;div class="login-section #if($showSignup)unified#end"&gt;
                #applyDecorator("form-aui")
                    #decoratorParam("formName" "loginform")
                    #decoratorParam("submitAction"  "$req.contextPath/dologin.action")
                    #decoratorParam("editAction" "$req.contextPath/login.action")
                    #decoratorParam("editMode" "true")
                    #decoratorParam("formStyle" "login-form-container")

                    &lt;h2&gt;$action.getText('login.name')&lt;/h2&gt;

                    #if($logout)
                        &lt;div class="aui-message success shadowed closeable"&gt;
                            &lt;p&gt;$i18n.getText("successful.logout.message")&lt;/p&gt;
                        &lt;/div&gt;
                    #end
                    #parse ('/template/includes/actionerrors.vm')
                    &lt;fieldset class="compact-form-fields"&gt;
                        #assistiveLegend("accessibility.form.login")
                        #if($action.isElevatedSecurityCheckRequired())
                            #bodytag( "TextField" "label='username.accesskey'" "name='os_username'" "theme='aui'")
                                #param("focus" "0")
                            #end
                            #bodytag( "Password" "label='password.accesskey'" "name='os_password'" "theme='aui'") #end
                            &lt;div id="captcha-container" class="field-group"&gt;
                                &lt;label id="captcha-reponse-label" for="captcha-response"&gt;
                                    ## link in login.elevatedsecuritycheck.assistive has 'tabindex="5"'
                                    &lt;span class="assistive"&gt;$i18n.getText("login.elevatedsecuritycheck.assistive")&lt;/span&gt;
                                &lt;/label&gt;
                                #set($captchaId = $captchaManager.generateCaptchaId())
                                ## assign reload a tabindex greater than 0 to remove it from the default tab order
                               &lt;a class="reload" href="${req.contextPath}/dologin.action?os_username=${action.os_username}" tabindex="1" title="$generalUtil.escapeXml($i18n.getText('login.elevatedsecuritycheck.captcha.reload.title'))"&gt;
                                    &lt;img src="${req.contextPath}/images/icons/refresh_grey_16.png" alt="$generalUtil.escapeXml($i18n.getText('login.elevatedsecuritycheck.captcha.reload.alt'))" /&gt;
                                &lt;/a&gt;
                                #captchaImage($captchaId)
                            &lt;/div&gt;
                            &lt;div class="field-group"&gt;
                                &lt;input id="captcha-response" class="text" type="text" name="captchaResponse" value="" placeholder="$i18n.getText('captcha.challenge')"&gt;
                                #fielderrorAUI('captcha')
                            &lt;/div&gt;
                            #bodytag( "Component" "label='remember.accesskey'" "name='os_cookie'" "value='false'" "theme='aui'" "template='onofflist.vm'") #end
                        #else
                            #bodytag( "TextField" "label='username.accesskey'" "name='os_username'" "theme='aui'")
                                #param("focus" "0")
                            #end
                            #bodytag( "Password" "label='password.accesskey'" "name='os_password'" "theme='aui'") #end
                            #bodytag( "Component" "label='remember.accesskey'" "name='os_cookie'" "value='false'" "theme='aui'" "template='onofflist.vm'") #end
                        #end

                        &lt;div class="field-group form-buttons compact-form-buttons"&gt;
                            &lt;input id="loginButton" class="aui-button aui-style aui-button-primary" name="login" type="submit" value="$i18n.getText('login.button')"/&gt;
                            #if ($action.isShowForgottenPasswordHelp())
                                &lt;a id="forgot-password" class="aui-button aui-style aui-button-link" href="${req.contextPath}/forgotuserpassword.action"&gt;$i18n.getText("forgot.password")&lt;/a&gt;
                            #end
                        &lt;/div&gt;
                        &lt;input type="hidden" name="os_destination" value="$!generalUtil.escapeXml($!os_destination)"/&gt;
                    &lt;/fieldset&gt;
                    #if ($showSignup)
                        &lt;div id="signupMessage" class="aui-message"&gt;&lt;p&gt;$i18n.getText("signup.for.an.account")&lt;/p&gt;&lt;/div&gt;
                    #end
                #end
            &lt;/div&gt; ## login-section

            #if ($showSignup)
            &lt;div class="signup-section"&gt;
	            #applyDecorator("form-aui")
	                #decoratorParam("formName" "signupform")
	                #decoratorParam("submitAction" "$req.contextPath/dosignup.action")
	                #decoratorParam("editAction" "$req.contextPath/signup.action")
	                #decoratorParam("editMode" "true")
	                #decoratorParam("formStyle" "login-form-container signup")
	                #decoratorParam("autocompleteDisabled" true)

	                &lt;h2&gt;$action.getText("sign.up")&lt;/h2&gt;

                    &lt;fieldset class="right-aligned-form-fields"&gt;
	                    #assistiveLegend("accessibility.signup.legend")
	                    #bodytag( "TextField" "label='fullname.name.bothcaps'" "name='fullName'" "theme='aui'" )
                            #param("focus" "0")
                        #end
                        #bodytag( "TextField" "label='email.name'" "name='email'" "theme='aui'" )
	                        #param("type" "email")
	                    #end
	                    #bodytag( "TextField" "label='username.name'" "name='username'" "theme='aui'" ) #end
                        #bodytag( "Password" "label='password.name'" "name='password'" "theme='aui'" ) #end
                        #bodytag( "Password" "label='confirm.password.name'" "name='confirm'" "theme='aui'" ) #end
                        #tag( "Hidden" "name='token'" "value='$!action.token'" )

                        #parse ("/pages/includes/captcha-form-elements.vm")

	                    &lt;div class="field-group form-buttons compact-form-buttons"&gt;
                            &lt;input id="signupButton" class="aui-button aui-style aui-button-primary" name="signupButton" type="submit" value="$i18n.getText('sign.up')" /&gt;
	                    &lt;/div&gt;
	                &lt;/fieldset&gt;
                    &lt;div id="loginMessage" class="aui-message"&gt;&lt;p&gt;$i18n.getText("signup.for.an.account.login")&lt;/p&gt;&lt;/div&gt;
	            #end
            &lt;/div&gt; ## signup-section
            #end
        #end
        &lt;/div&gt;
        #if ($action.clusterManager.isClustered())
            &lt;content tag="coherence-copyright"&gt;
                &lt;div class="smalltext" id="coherence-copyright"&gt;
                    $i18n.getText("coherence.copyright.notice", [$buildInfo.buildYear])
                &lt;/div&gt;
            &lt;/content&gt;
        #end
        #if ($action.isBrowserLanguageEnabled())
            &lt;content tag="login-language"&gt;
                &lt;ul id="login-language"&gt;
                    #foreach ($lang in $action.getInstalledLanguages())
                        &lt;li&gt;
                            &lt;a href="login.action?language=$lang.name"&gt;$lang.capitalDisplayName&lt;/a&gt;
                        &lt;/li&gt;
                    #end
                &lt;/ul&gt;
            &lt;/content&gt;
        #end
	&lt;/body&gt;
&lt;/html&gt;

Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2013

I'm pretty sure that should work. My setup is a little different, so I can't test it directly right now, but you've got the gist. Basically, os_destination is the redirect URL for a successful login, and it's relative to the root.

0 votes
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2013

Set the value of the os_destination query string param after the login.action. For example:

login.action?os_destination=/display/doc/your+page

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events