问题
I am new to SiteFinity. This is the first time I have ever seen it.
I am trying to find out how to check to see if the user is logged in and if they are, do not load certain javascript files (we have a conflict that is causing problems with sitefinity's page editor)
So in the header I want to do something like
if(user_logged_in()) ... load js file here
Also I am trying to do this in the master template files.
Version 6.1 FYI
回答1:
You can try:
ClaimsManager.GetCurrentIdentity().IsAuthenticated
This will return whether or not the user is logged in but it sounds like you need to know if they are a backend user so maybe try:
ClaimsManager.GetCurrentIdentity().IsBackendUser
You'll need this using directive:
using Telerik.Sitefinity.Security.Claims;
回答2:
I think this might work for you. If the user is authenticated it will load you your .js file.
var isValidUser = SecurityManager.AuthenticateUser(UserManager.GetDefaultProviderName(), userName, userPassword, true);
if (isValidUser == UserLoggingReason.Success){
JavaScriptEmbedControl scriptToEmbed = new JavaScriptEmbedControl();
scriptToEmbed.Url = "path-to-file.js";
scriptToEmbed.ScriptEmbedPosition = Telerik.Sitefinity.Web.UI.PublicControls.Enums.ScriptEmbedPosition.InPlace;
this.form1.Controls.Add(scriptToEmbed);
}
来源:https://stackoverflow.com/questions/24090554/sitefinity-if-user-logged-in