Esempio n. 1
0
        public object Post(CreateUserRequest request)
        {
            var userAuth    = request.ConvertTo <UserAuth>();
            var createdUser = userAuthRepository.CreateUserAuth(userAuth, request.Password ?? CreateRandomPassword());

            return(Get(new GetUserByIdRequest {
                Id = createdUser.Id
            }));
        }
Esempio n. 2
0
        private static void CreateUser(IUserAuthRepository userRepo, IUserAuth user, string password)
        {
            string hash;
            string salt;

            new SaltedHash().GetHashAndSaltString(password, out hash, out salt);
            user.Salt         = salt;
            user.PasswordHash = hash;
            userRepo.CreateUserAuth(user, password);
        }
        // Add initial Users to the configured Auth Repository
        private void AddSeedUsers(IUserAuthRepository authRepo)
        {
            if (authRepo.GetUserAuthByUserName("*****@*****.**") == null)
            {
                var testUser = authRepo.CreateUserAuth(new UserAuth
                {
                    DisplayName = "Test User",
                    Email       = "*****@*****.**",
                    FirstName   = "Test",
                    LastName    = "User",
                }, "p@55wOrd");
            }

            if (authRepo.GetUserAuthByUserName("*****@*****.**") == null)
            {
                var roleUser = authRepo.CreateUserAuth(new UserAuth
                {
                    DisplayName = "Test Manager",
                    Email       = "*****@*****.**",
                    FirstName   = "Test",
                    LastName    = "Manager",
                }, "p@55wOrd");
                authRepo.AssignRoles(roleUser, roles: new[] { "Manager" });
            }

            if (authRepo.GetUserAuthByUserName("*****@*****.**") == null)
            {
                var roleUser = authRepo.CreateUserAuth(new UserAuth
                {
                    DisplayName = "Admin User",
                    Email       = "*****@*****.**",
                    FirstName   = "Admin",
                    LastName    = "User",
                }, "p@55wOrd");
                authRepo.AssignRoles(roleUser, roles: new[] { "Admin" });
            }
        }
Esempio n. 4
0
File: App.cs Progetto: TIHan/MonoWeb
        private void CreateUser(IUserAuthRepository userRep, int id, string userName, string email, string password, List<string> roles = null, List<string> permissions = null)
        {
            string hash;
            string salt;
            new SaltedHash().GetHashAndSaltString(password, out hash, out salt);

            userRep.CreateUserAuth(new UserAuth {
            Id = id,
            DisplayName = "DisplayName",
            Email = email,
            UserName = userName,
            FirstName = "FirstName",
            LastName = "LastName",
            PasswordHash = hash,
            Salt = salt,
            Roles = roles,
            Permissions = permissions
            }, password);
        }
Esempio n. 5
0
        private static void CreateUser(IUserAuthRepository repository, int id, string username, string displayName, string email, string password)
        {
            string hash;
            string salt;

            new SaltedHash().GetHashAndSaltString(password, out hash, out salt);

            repository.CreateUserAuth(new UserAuth
            {
                Id           = id,
                DisplayName  = displayName,
                Email        = email ?? "as@if{0}.com".Fmt(id),
                UserName     = username,
                FirstName    = "FirstName",
                LastName     = "LastName",
                PasswordHash = hash,
                Salt         = salt,
            }, password);
        }
Esempio n. 6
0
File: App.cs Progetto: TIHan/MonoWeb
        private void CreateUser(IUserAuthRepository userRep, int id, string userName, string email, string password, List <string> roles = null, List <string> permissions = null)
        {
            string hash;
            string salt;

            new SaltedHash().GetHashAndSaltString(password, out hash, out salt);

            userRep.CreateUserAuth(new UserAuth {
                Id           = id,
                DisplayName  = "DisplayName",
                Email        = email,
                UserName     = userName,
                FirstName    = "FirstName",
                LastName     = "LastName",
                PasswordHash = hash,
                Salt         = salt,
                Roles        = roles,
                Permissions  = permissions
            }, password);
        }
        private static void CreateUser(IUserAuthRepository repository, int id, string username, string displayName, string email, string password)
        {
            string hash;
            string salt;
            new SaltedHash().GetHashAndSaltString(password, out hash, out salt);

            repository.CreateUserAuth(new UserAuth
            {
                Id = id,
                DisplayName = displayName,
                Email = email ?? "as@if{0}.com".Fmt(id),
                UserName = username,
                FirstName = "FirstName",
                LastName = "LastName",
                PasswordHash = hash,
                Salt = salt,
            }, password);
        }
Esempio n. 8
0
 private static void CreateUser(IUserAuthRepository userRepo, IUserAuth user, string password)
 {
     string hash;
     string salt;
     new SaltedHash().GetHashAndSaltString(password, out hash, out salt);
     user.Salt = salt;
     user.PasswordHash = hash;
     userRepo.CreateUserAuth(user, password);
 }
Esempio n. 9
0
        private static void AddUser(IUserAuthRepository userRepository)
        {
            //Add a user for testing purposes
            string hash;
            string salt;
            new SaltedHash().GetHashAndSaltString("test", out hash, out salt);

            userRepository.CreateUserAuth(
                new UserAuth
                    {
                        Id = 1,
                        DisplayName = "DisplayName",
                        Email = "*****@*****.**",
                        UserName = "******",
                        FirstName = "FirstName",
                        LastName = "LastName",
                        PasswordHash = hash,
                        Salt = salt,
                    },
                "test");
        }
Esempio n. 10
0
        private static void SeedUsers(IUserAuthRepository users)
        {
            //check to see if user exists
            if (users.GetUserAuthByUserName("admin.user") == null)
            {
                //create user
                const string pwd = "password";
                string hash, salt;
                new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
                users.CreateUserAuth(new UserAuth
                    {
                        Id = 1,
                        DisplayName = "Admin User",
                        Email = "*****@*****.**",
                        UserName = "******",
                        FirstName = "Admin",
                        LastName = "User",
                        PasswordHash = hash,
                        Salt = salt,
                        Roles = new List<string> {RoleNames.Admin},
                        Permissions = new List<string> {"God"}
                    }, pwd);
            }

            //check to see if user exists
            if (users.GetUserAuthByUserName("joe.budget") == null)
            {
                //create user
                const string pwd = "password";
                string hash, salt;
                new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
                users.CreateUserAuth(new UserAuth
                    {
                        Id = 1,
                        DisplayName = "Joe BudgetHolder",
                        Email = "*****@*****.**",
                        UserName = "******",
                        FirstName = "Joe",
                        LastName = "BudgetHolder",
                        PasswordHash = hash,
                        Salt = salt,
                        Roles = new List<string> {"BudgetUser"},
                        Permissions = new List<string> {"GiveAward"}
                    }, pwd);
            }

            //check to see if user exists
            if (users.GetUserAuthByUserName("jane.employee") == null)
            {
                //create user
                const string pwd = "password";
                string hash, salt;
                new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
                users.CreateUserAuth(new UserAuth
                    {
                        Id = 1,
                        DisplayName = "Jane Employee",
                        Email = "*****@*****.**",
                        UserName = "******",
                        FirstName = "Jane",
                        LastName = "Employee",
                        PasswordHash = hash,
                        Salt = salt,
                    }, pwd);
            }
        }