Created
August 4, 2014 15:26
-
-
Save dampee/efde432b17383cc0e9a2 to your computer and use it in GitHub Desktop.
Create a new admin user in umbraco
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// ApplicationBase: prior to 4.8 | |
public class AdminUserPwdReset : ApplicationBase //: ApplicationStartupHandler | |
{ | |
public AdminUserPwdReset() | |
{ | |
var userTYpe = UserType.GetUserType(1); // admins | |
User adminUser = User.MakeNew("damiaan", "damiaan", hashPassword("default"), userTYpe); | |
adminUser.addApplication("users"); | |
adminUser.addApplication("settings"); | |
adminUser.addApplication("developer"); | |
adminUser.addApplication("media"); | |
adminUser.addApplication("content"); | |
adminUser.Save(); | |
} | |
string hashPassword(string password) | |
{ | |
HMACSHA1 hash = new HMACSHA1(); | |
hash.Key = Encoding.Unicode.GetBytes(password); | |
string encodedPassword = Convert.ToBase64String(hash.ComputeHash(Encoding.Unicode.GetBytes(password))); | |
return encodedPassword; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment