如何检查用户是否登录,不是会员? [英] How to check if user is logged on, Not Member?
问题描述
尝试了2种不同的方法来检查用户是否从前端的用户控制代码(.cs)文件中登录了Umbraco Administration:
Have tried 2 different methods to check if the user is logged into Umbraco Administration from the front-end in a User Controls Code-Behind (.cs) file:
Page.User.Identity.IsAuthenticated
和
umbraco.library.IsLoggedOn()
即使我已登录,这两个选项始终都返回false.如何检查用户是否正确登录?试图在前端获得这个.有没有办法在前端做到这一点?使用Umbraco版本4.6.1.
Both of these always returns false, even when I am logged in. How to check if user is logged in correctly?? Trying to get this on the front-end. Is there a way to do this on the front-end? Using Umbraco Version 4.6.1.
此外,在Umbraco的管理部门中,这些用户是用户,而不是会员!因此,我需要知道用户是否登录了Umbraco,而不是会员!
Furthermore, In the Administration of Umbraco, these are Users, not Members! So, I need to know if a User is logged into Umbraco, not Member(s)!
推荐答案
没关系,想通了...
Nevermind, figured it out...
private bool _IsAdminLoggedIn = false;
if (umbraco.helper.GetCurrentUmbracoUser() != null)
{
_IsAdminLoggedIn = !string.IsNullOrEmpty(umbraco.helper.GetCurrentUmbracoUser().UserType.Alias) && umbraco.helper.GetCurrentUmbracoUser().UserType.Alias == "admin";
}
现在 _IsAdminLoggedIn
返回true或false取决于用户类型"admin"是否已登录到Umbraco!
Now _IsAdminLoggedIn
returns true or false depending if the UserType "admin" is logged into Umbraco or not!
干杯:)
这篇关于如何检查用户是否登录,不是会员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!