Allow user registration

This information is still applicable to v6

On the Security page you can configure the PO that should be shown and the application group for the user rights. For most applications the Register PO will be a new virtual Persistent Object with at least an email address (username) and password attribute. The following code shows an example POActions class for the Register PO.

public class RegisterActions : PersistentObjectActionsReference<AdventureWorksEntityContainer, object>
{
    public override void OnSave(PersistentObject obj)
    {
        if (!CheckRules(obj))
            return;

        var userName = (string)obj["Email"];
        if (Manager.Current.GetUser(userName) != null)
            throw new FaultException("That user already exists. Use the forgot password functionality to reset your password.");

        Manager.Current.CreateNewUser(userName, (string)obj["Password"], profile: new Dictionary<string, string> { { "Registered", "self" } });

        obj.AddNotification("You can now login using your email and password.", NotificationType.OK);
    }
}

Last updated

Was this helpful?