Developer forum

Forum » CMS - Standard features » set password email using "Send user details" in admin

set password email using "Send user details" in admin

Thomas Jensen
Reply

Hi

 

I'm trying to do that same as in post
https://doc.dynamicweb.com/forum/templates/templates/set-password-email-using-marketing
sending a mail with a link to reset password,
but not from marketing from  "Send user details" under a user 

Using the "Send recovery mail" gives me the same issue

 

from the marketing post

if (Pageview != null && Pageview.Context != null)
{
    var user = Pageview.Context.GetValue("User") as User;
    if (user != null)
    {
        string token = System.Guid.NewGuid().ToString();
        string resetLink = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(GetPageIdByNavigationTag("SignInPage")) + "?Username=" + user.UserName + "&RecoveryToken=" + token;
        
        // Set the token on the user
        user.PasswordRecoveryTokenExpirationTime = System.DateTime.UtcNow.AddHours(Dynamicweb.Configuration.SystemConfiguration.Instance.GetInt32("/Globalsettings/Modules/UserManagement/ExtranetPasswordSecurity/RecoveryTokenTimeout"));
        user.PasswordRecoveryToken = token;
        user.Save();
        
    }
}

 

I can make a token, and build the link

int SignInPage =  6502;
var primaryDomain = currentArea.DomainLock;

string token = System.Guid.NewGuid().ToString();
string resetLink = "https//" + primaryDomain +  Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(SignInPage) + "?Username=" + GetString("DWUsers:User:Username") + "&RecoveryToken=" + token; 

but that is without having the "user" variable defined

How do I "Set the token on the user"?
or how do i define the user?

it is not a Pageview or a Pageview.Context

 

Non of these work

var user = GetValue("DWUsers:User:User") as User;
var user = GetValue("DWUsers:User") as User;
var user = GetValue("DWUsers") as User;

 

/ Thomas


Replies

 
Thomas Jensen
Reply

Hi

A colleague, found the solution in API

var user = Dynamicweb.Security.UserManagement.User.GetUserByUserName(GetString("DWUsers:User:Username"));

The marketing solution would probably work with this single change, and no need for a special build recovery link

Look for more info in API
https://doc.dynamicweb.com/api/html/86de24bb-7acf-1733-a889-6610f4cf1fbe.htm
and
https://doc.dynamicweb.com/api/html/663534db-968b-9176-afa9-afa529e4f45c.htm

 
/ Thomas

 

You must be logged in to post in the forum