2012-01-13 61 views
1

我正在使用具有用户注册的自定义dnn注册表单:已验证。DNN中的注册表单发送验证码时发出的问题

下面是代码:

TokenReplace tr = new TokenReplace(Scope.SystemMessages, User.Profile.PreferredLocale, this.PortalSettings, this.User); 
string verificationCode = tr.ReplaceEnvironmentTokens("[User:VerificationCode]"); 
string verificationUrl = Globals.NavigateURL(PortalSettings.LoginTabId) + "?username=" + Server.UrlEncode(User.Username) + "&verificationcode=" + Server.UrlEncode(verificationCode); 

在这段代码中,我得到的verificationCode=*******

价值为什么在明文格式不显示verificationCode请帮我在这里。

很多-2提前感谢你。

回答

2

由于AccessingUser(运行上述代码的用户)没有足够的权限来满足显示验证代码所需的访问范围级别,所以将令牌替换为星号。

在UserInfo类的GetProperty方法中,它要求“AccessingUser”既可以是管理员,也可以是用户自己为了令牌被渲染而不被屏蔽。它通过HttpContext.Current.Items(“UserInfo”)确定访问用户,因此为了允许令牌正确呈现,需要在调用ReplaceEnvironmentTokens函数之前将访问用户设置为门户管理员。

实施例:

TokenReplace tr = new TokenReplace(Scope.SystemMessages, User.Profile.PreferredLocale, this.PortalSettings, this.User); 

tr.AccessingUser = New UserController().GetUser(objPortal.PortalId, PortalSettings.AdministratorId) 

string verificationCode = tr.ReplaceEnvironmentTokens("[User:VerificationCode]"); 
string verificationUrl = Globals.NavigateURL(PortalSettings.LoginTabId) + "?username=" + Server.UrlEncode(User.Username) + "&verificationcode=" + Server.UrlEncode(verificationCode); 
+0

嗯 - 即使当我通过在管理员用户结果仍******* - 见http://www.dnnsoftware.com/answers/ReplaceEnvironmentTokens-UserVerificationCode -stopped-工作-在-73 – Rodney 2014-12-07 10:33:22