SiteFinity if user logged in

本小妞迷上赌 提交于 2019-12-23 03:45:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!