Ejemplo n.º 1
0
        public void Register(User u)
        {
            UsersRepository ur = new UsersRepository();
            RolesRepository rr = new RolesRepository();

            ur.Entity = rr.Entity; //The memory location of ur is equall to the memory location of rr (is the same object.)  will keep 1 memory location.

            u.Id       = Guid.NewGuid();
            u.Password = Encryption.HashPassword(u.Password);

            //Generating keys into db
            var myKeys = Encryption.GenerateAsymmetricKeys();

            u.PublicKey  = myKeys.PublicKey;
            u.PrivateKey = myKeys.PrivateKey;

            ur.AddUser(u);


            var r = rr.GetRole("User");

            //var r = rr.GetRole("Admin");
            rr.AllocateRoleToUser(u, r);
        }