After logging on to the system, you must adjust the homepage display so that the system interface is displayed after you log on.
Determine the isauthenticated method of the request before and after logon. Because different scripts need to be executed through the server segment code, the Loder public code should be extracted independently in a script block, and different scripts should be in different codes, the final code is as follows:
<SCRIPT>
Ext. loader. setconfig ({
Enabled: True,
Paths :{
'Ext. UX ': 'scripts/extjs/UX'
}
});
</SCRIPT>
@{
If (request. isauthenticated)
{
<SCRIPT>
</SCRIPT>
}
Else
{
<SCRIPT>
Ext. Require ('ext. UX. login ');
Ext. onready (function (){
If (ext. blank_image_url.substr (0, 4 )! = "Data "){
Ext. blank_image_url = "content/images/s.gif ";
}
Ext. UX. login. Show ();
})
</SCRIPT>
}
}
Because you need to call the application to generate the interface, you need to let ext JS know the application directory, so Add the following code to the paths of Loader:
'Simplecm': 'scripts/app'
After Authentication, you need to write user information such as an object to control the permissions of the application. Therefore, add the following code:
VaR roles = roles. getrolesforuser (user. Identity. Name );
VaR rolesstring = "";
Foreach (var c in roles)
{
Rolesstring + = string. Format ("'{0}',", C );
}
Rolesstring = rolesstring. substring (0, rolesstring. Length-1 );
<SCRIPT>
Simplecms. userinfo = {
Roles :[
@ Html. Raw (rolesstring)
]
};
</SCRIPT>
Here, the user role is simply written into the userinfo object. If you need other user information, you can construct the object based on the actual situation, as long as it is easy to access.
There is a problem here, that is, all objects simplecms may be null here, so you need to call the NS method of ext to name it. This can be added to the loader and the code is as follows:
Ext. NS ('simplecm ');
Now, open the home page in the browser and log on with Admin. In firebug, the source code shown in 16 is displayed, indicating that you have already logged on separately before and after logon.
Figure 16 page source code displayed in firebug
The homepage has been adjusted. The next step is to write what ext js mvc requires.
Code: http://download.csdn.net/detail/tianxiaode/4572323