Developer forum

Forum » CMS - Standard features » Send link to reset page doesn't seem to work

Send link to reset page doesn't seem to work

Manon Wekking
Reply

Hello,

I was trying to change the recovery method in one of our solutions to Send link to reset page. However when I changed the setting, suddenly the recovery page doesn't show anything anymore. Of course I suspected the template to be not correct but I can't seem to find any fault in it. Actually it's basically the default template still.

In my quest for a solution I then went to the wrap demo environment: http://wrap.dynamicweb-cms.com. I changed the setting there in the same manner and now I got errors in the template file. When I change the file to our template file the same thing happens as in our solution, nothing is shown. When I change the setting again then it works normally. It almost seems that for the other options another template is used, as I don't see how syntax errors are ignored when another option is chosen. You can check it in the wrap demo environment.

What's going on here? Am I doing something wrong? I can't find any further documentation on how to implement it so I figure it's so easy as just to configure it in the back-end.

Kind regards,

Manon Wekking


Replies

 
Nicolai Pedersen
Reply

Hi Manon

Did you login to the wrap admin? And how??

I can see the template was modified and now it does not work - there is a razor syntax error in it.

BR Nicolai

 
Manon Wekking
Reply

Hi,

With administrator administrator as the install document of the wrap states?

I did try to put it back to the original template, I think I succeeded. Those errors I got the first time I changed the setting. I've changed it to have no errors, but then I saw nothing.

Do you want me to remove the syntax errors again?

Kind regards,

Manon

 
Nicolai Pedersen
Reply

Ok. You should not login to our solution and change it. It kind of breaks what everyone gets out...

Well - It seems like you have an error in the template - try fixing that on your solution and create a case with the service desk if you need help to configure this.

BR Nicolai

 
Manon Wekking
Reply

Hey Nicolai,

I was not aware of that. I thought the demo environment was just there for that purpose.  I could try and get a demo environment running locally I suppose.

Our template doesn't contain an error. Our own solution differs from the demo environment.

Our code looks like this: (can't seem to find a code tag or something, so I hope it renders well)

@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
    
<div class="container">
    <div class="row">
        <div class="col-md-6 col-sm-6 col-xs-12">
            <div class="wp-block default user-form">
                @if (!string.IsNullOrWhiteSpace(GetString("UserManagement:User.Login.Action=Recovery")))
                {
                    <h3>
                        @Translate("Get back into your account", "Get back into your account")
                    </h3>
                    <br />

                    <form method="post" action="/Default.aspx?id=@GetString("Global:Page.ID")">
                        <input type="hidden" name="ForgotPasswordMailTemplate" value="@GetString("UserManagement:User.Login.EmailTemplate")" />
                        <input type="hidden" name="ForgotPasswordSenderEmail" value="@GetString("UserManagement:User.Login.EmailSender")" />
                        <input type="hidden" name="ForgotPasswordMailSubject" value="@GetString("UserManagement:User.Login.EmailSubject")" />
                        @if (GetInteger("UserManagement:User.Login.FoundUsersCount") == 0 || GetInteger("UserManagement:User.Login.FoundUsersCount") >= 1)
                        {
                            <div class="info-pane error">@Translate("User not found!", "User not found!")</div>
                        }
                        @foreach (LoopItem loginfield in GetLoop("UserManagement:User.Login.Fields"))
                        {
                        <div class="pr-field">
                            <label class="title" for="@loginfield.GetString("Field.Name")">
                                @loginfield.GetString("Field.Title"):
                            </label>
                            @loginfield.GetString("Field.Input")
                            @if (!string.IsNullOrWhiteSpace(loginfield.GetString("Field.Error")))
                            {
                                <label class="error" for="@loginfield.GetString("Field.Name")">@loginfield.GetString("Field.Error")</label>
                            }
                        </div>
                        }
                        <div class="pr-field commands">
                            <button type="submit" name="LoginAction" value="Recovery">@Translate("Submit", "Submit")</button>
                        </div>
                    </form>
                }

                @if (GetString("UserManagement:User.Login.Action") == "RecoveryLinkSent")
                {
                    <div class="info-pane">
                        <div class="title">@Translate("Check your email", "Check your email")</div>
                        <div class="body">
                            @Translate("Check your email - we sent you an email with a link. Click it to continue to reset your password.", "Check your email - we sent you an email with a link. Click it to continue to reset your password.")
                        </div>
                    </div>
                }

                @if (GetString("UserManagement:User.Login.Action") == "NewPasswordForm")
                {
                    if (GetBoolean("UserManagement:User.Login.RecoveryToken.FoundUser") != true)
                    {
                        <div class="info-pane">
                            <div class="title">@Translate("Something went wrong", "Something went wrong")</div>
                            <div class="body">
                                @Translate("Try recover password", "Try recover password") <a href="/default.aspx?id=@GetString("Global:Page.ID")">@Translate("again", "again")</a>.
                            </div>
                        </div>
                    }
                    if (GetBoolean("UserManagement:User.Login.RecoveryToken.FoundUser") == true && GetBoolean("UserManagement:User.Login.RecoveryToken.OutOfDate") == true)
                    {
                        <div class="info-pane">
                            <div class="title">@Translate("The recovery password link out of date", "The recovery password link out of date")</div>
                            <div class="body">
                                @Translate("The recovery password link out of date", "The recovery password link out of date") @Translate("Try recover password", "Try recover password") <a href="/default.aspx?id=@GetString("Global:Page.ID")">@Translate("again", "again")</a>.
                            </div>
                        </div>
                    }
                    if (GetBoolean("UserManagement:User.Login.RecoveryToken.FoundUser") == true && GetBoolean("UserManagement:User.Login.RecoveryToken.OutOfDate") != true)
                    {
                        <h3 class="head">
                            @Translate("Choose a new password", "Choose a new password")
                            <br />
                            <small>
                                <strong>@Translate("Notice", "Notice"):</strong> @Translate("A strong password is a combination of letters and punctuation marks", "A strong password is a combination of letters and punctuation marks")
                            </small>
                        </h3>
                        <form method="post" action="/Default.aspx?id=@GetString("Global:Page.ID")">
                            <input type="hidden" name="RecoveryToken" value="@GetString("UserManagement:User.Login.RecoveryToken")" />
                            <input type="hidden" name="ForgotPasswordMailTemplate" value="@GetString("UserManagement:User.Login.EmailTemplate")" />
                            <input type="hidden" name="ForgotPasswordSenderEmail" value="@GetString("UserManagement:User.Login.EmailSender")" />
                            <input type="hidden" name="ForgotPasswordMailSubject" value="@GetString("UserManagement:User.Login.EmailSubject")" />

                            <div class="pr-field">
                                <label class="title" for="@GetString("UserManagement:User.Login.Field.NewPassword.Name")">
                                    @Translate("New Password", "New Password"):
                                </label>
                                @GetString("UserManagement:User.Login.Field.NewPassword.Input")
                                @if (!string.IsNullOrWhiteSpace(GetString("UserManagement:User.Login.Field.NewPassword.Error")))
                                {
                                    <label class="error" for="@GetString("UserManagement:User.Login.Field.NewPassword.Name")">@GetString("UserManagement:User.Login.Field.NewPassword.Error")</label>
                                }
                            </div>
                            <div class="pr-field">
                                <label class="title" for="@GetString("UserManagement:User.Login.Field.NewPasswordConfirm.Name")">
                                    Confirm Password:
                                </label>
                                @GetString("UserManagement:User.Login.Field.NewPasswordConfirm.Input")
                                @if (!string.IsNullOrWhiteSpace(GetString("UserManagement:User.Login.Field.NewPasswordConfirm.Error")))
                                {
                                    <label class="error" for="@GetString("UserManagement:User.Login.Field.NewPasswordConfirm.Name")">@GetString("UserManagement:User.Login.Field.NewPasswordConfirm.Error")</label>
                                }
                            </div>
                            <div class="pr-field commands">
                                <button type="submit" name="LoginAction" value="ChangePassword">@Translate("Submit", "Submit")</button>
                            </div>
                        </form>
                    }
                }

                @if (GetString("UserManagement:User.Login.Action") == "PasswordChanged")
                {
                    <div class="info-pane">
                        <div class="title">Congratulations!</div>
                        <div class="body">
                            Password changed
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
</div>

--- END CODE ---

I think this is basically the default form. If there are errors in the template then I am not sure where to look. Again if I use another setting the recovery part is shown, but from the demo environment I almost get the idea another template is used in that case.

Kind regards,

Manon Wekking

 
Manon Wekking
Reply

The error is indeed in the template. My colleague pointed out that the first check in the default file is not correct:

@if (!string.IsNullOrWhiteSpace(GetString("UserManagement:User.Login.Action=Recovery")))

This should most likely be @if (GetString("UserManagement:User.Login.Action") == "Recovery") or something similar like the other checks.

The thing that confused me is that there's two templates you can set in the Module for Login. Apparently the reset_password template is used for the first two options and the recovery template for the third option. This makes sense now that I know, but I was thinking the reset template was used for resetting your password after the link, this is however not the case, the recovery template should also contain the form for resetting the password.

Thanks for your help, maybe this will help someone in the future. I think it would also be a good idea to change the default template so it works correctly out of the box.

issueResetPasswordDW.png
 
Nicolai Pedersen
Reply

Hi Manon

Great you found the error - and thanks for sharing the result.

I will pass this on to the right people!

Thanks, Nicolai

 
Lars Larsen
Lars Larsen
Reply

 

You must be logged in to post in the forum