Ive tried searching the forum for this question but havent found any sollution so far.
Is it possible to create a "front-end page" where a visitior can create a umbraco User account, so he can login to the back-end of umbraco. This "user" will have limited rights ofcourse. Im hoping that someone has a working example since Im more into the front-end development and xslt.
I don't have a fully working example, but you should definitely be able to do this using the API (via the User object). Off the top of my head here is a quick example (not tested).
// Get the UserType reference (built-in are Administrators, Writer, Editors) var userType = umbraco.BusinessLogic.UserType.GetAllUserTypes().FirstOrDefault(ut => ut.Name == "Editors");
// Create the user var newUser = umbraco.BusinessLogic.User.MakeNew("name", "loginname", "password", "email", userType);
// Set start nodes newUser.StartMediaId = -1; newUser.StartNodeId = -1;
// Grant access to applications (sections) newUser.addApplication("content"); newUser.addApplication("media");
// Save newUser.Save();
You'll of course need to create the form yourself, probably easiest to use Razor to do this. You could probably also make this into a Contour workflowtype if that's the route you prefer.
Also, I'm assuming you have a good reason to do this rather than using the Membership API and front-end pages, but if you think that would work for you it's probably a better option than giving visitors access to Umbraco...
I have one more question. I got it to work using a form. Only problem i am having now is that the password that gets send to the database doesnt work. I think this is because it doesnt get changed to a encrypted password. Any ideas how i can make this work ?
I now have the most basic stuff working. And will continue to develope it further. Will post the code below if anyone is interrested :)
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Security; using System.Security.Cryptography; using System.Text; using umbraco; using umbraco.BusinessLogic; using umbraco.cms.businesslogic.member;
public partial class usercontrols_memberC_usercontrol : System.Web.UI.UserControl { // Error format private const string ErrorFormat = "<p class=\"formerror\">{0}</p>"; string hashPassword(string password) { HMACSHA1 hash = new HMACSHA1(); hash.Key = Encoding.Unicode.GetBytes(password);
// Get the UserType reference (built-in are Administrators, Writer, Editors) var userType = umbraco.BusinessLogic.UserType.GetAllUserTypes().FirstOrDefault(ut => ut.Name == "Editors");
// Create the user
var newUser = umbraco.BusinessLogic.User.MakeNew(tbName.Text, tbUsername.Text, hashPassword(tbPassword.Text), tbEmail.Text, userType);
// Set start nodes newUser.StartMediaId = -1; newUser.StartNodeId = -1;
// Grant access to applications (sections) newUser.addApplication("content"); newUser.addApplication("media");
// Save newUser.Save(); litError.Text = string.Format(ErrorFormat, "Gebruiker is toegevoegd"); } else { // Error, member already exists with email or username used litError.Text = string.Format(ErrorFormat, "Gebruiker bestaat al"); } } }
Register Page Back-End User
Hello,
Ive tried searching the forum for this question but havent found any sollution so far.
Is it possible to create a "front-end page" where a visitior can create a umbraco User account, so he can login to the back-end of umbraco. This "user" will have limited rights ofcourse. Im hoping that someone has a working example since Im more into the front-end development and xslt.
Hope someone can help me.
Greetings,
Martijn
Hi Martijn,
I don't have a fully working example, but you should definitely be able to do this using the API (via the User object). Off the top of my head here is a quick example (not tested).
You'll of course need to create the form yourself, probably easiest to use Razor to do this. You could probably also make this into a Contour workflowtype if that's the route you prefer.
Also, I'm assuming you have a good reason to do this rather than using the Membership API and front-end pages, but if you think that would work for you it's probably a better option than giving visitors access to Umbraco...
-Tom
Thanks Tom for the reply i will go try if i can make it work :)
Cheers,
Martijn
Hello Tom,
I have one more question.
I got it to work using a form. Only problem i am having now is that the password that gets send to the database doesnt work. I think this is because it doesnt get changed to a encrypted password. Any ideas how i can make this work ?
Thanks,
Martijn
Try using this:
-Tom
Thanks for your help Tom,
I now have the most basic stuff working. And will continue to develope it further.
Will post the code below if anyone is interrested :)
is working on a reply...