Exemple #1
0
 public AomFieldObjectServiceTests()
 {
     // The default mock user
     mockUser = new CoreUser
     {
     };
 }
 public FieldTypesServiceTests()
 {
     // The default mock user
     mockUser = new CoreUser
     {
     };
 }
 public RelationshipMetaServiceTests()
 {
     // The default mock user
     mockUser = new CoreUser
     {
     };
 }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                ApplicationDbContext db = new ApplicationDbContext();
                CoreUser             u  = new CoreUser();
                u.IdNumber = model.IDNumber;
                u.Name     = model.Name;
                u.Phone    = model.Phone;
                u.Surname  = model.Surname;
                u.UserName = model.Email;
                db.CoreUsers.Add(u);
                db.SaveChanges();
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }


            return(View(model));
        }
Exemple #5
0
        /// <summary>
        /// Method to create new user account
        /// Validates user does not exist based on email address
        /// </summary>
        /// <param name="coreUser"></param>
        /// <returns>Completed Task if new user account is created</returns>
        public async Task <long> CreateNewUserAccount(CoreUser coreUser)
        {
            try
            {
                //pull any user that exists with email address provided
                var existingUser = await _userRepository.GetUserByEmail(coreUser.Email);
            }
            catch (Exception)
            {
                //map from core to db user
                var dbUser = EfUserMapper.CoreToDbUser(coreUser);
                dbUser.Created = DateTime.Now;
                dbUser.Updated = DateTime.Now;

                //encrypt password
                var hashCode = _passwordService.CreatePasswordHash(coreUser.Password);
                dbUser.Password = hashCode;

                //create new user account with repository method
                var userId = await _userRepository.CreateNewUserAccount(dbUser);

                return(userId);
            }

            //validate that user is null
            throw new Exception("User with associated email exists.");
        }
 public MigrationHistoryServiceTests()
 {
     // The default mock user
     mockUser = new CoreUser
     {
     };
 }
Exemple #7
0
        public async Task <ResultModel <JwtResult <CoreUser> > > RefreshToken(CoreUser user)
        {
            var resultObj = new ResultModel <JwtResult <CoreUser> >();

            var claims = GenerateClaims(user);
            //var principal = new ClaimsPrincipal(identity);
            var refreshTokenInfo = new RefreshTokenInfo()
            {
                UserId = user.Id,
                // Expired Date Refresh Token
                ExpiredDate = DateTime.Now.AddDays(37)
            };
            var identifier = user.CoreCredentials.First().Identifier;
            var jwt        = await TokenHelper.GenerateJwt(claims, _jwtFactory, identifier, _jwtOptions, new JsonSerializerSettings { Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore });

            var result = new JwtResult <CoreUser>
            {
                Token        = jwt,
                RefreshToken = TokenHelper.GenerateRefreshToken(refreshTokenInfo, new JsonSerializerSettings {
                    Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                })
            };

            resultObj.Status     = ResultStatus.Success;
            resultObj.ExtendData = result;

            _userDm.Update(user);
            return(resultObj);
        }
 public AomMetaServiceTests()
 {
     // The default mock user
     mockUser = new CoreUser
     {
     };
 }
Exemple #9
0
        public CoreUser Register(CoreUser user)
        {
            var addedUser = _context.Add(user);

            _context.SaveChanges();
            user.Username = addedUser.Entity.Username;
            return(user);
        }
        private IEnumerable <Claim> GetUserClaims(CoreUser user)
        {
            List <Claim> claims = new List <Claim>();

            claims.Add(new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()));
            claims.Add(new Claim(ClaimTypes.Name, user.Name));
            claims.AddRange(this.GetUserRoleClaims(user));
            return(claims);
        }
        public IActionResult Register([FromBody] CoreUser user)
        {
            if (user == null)
            {
                return(BadRequest());
            }

            CoreUser createdUser = _tweeterRepo.Register(user);


            return(CreatedAtRoute("GetUser", new { id = user.Username }, createdUser));
        }
        public async Task <IActionResult> NewPreliminaryApplication([FromBody] PreliminaryApplicationDto applicationDto)
        {
            var user = await _users.FindByNameAsync(applicationDto.Email, new CancellationToken(false));

            if (user != null)
            {
                return(BadRequest("Already pre-registered"));
            }

            var newUser = new IdentityUser()
            {
                Id                 = Guid.NewGuid().ToString(),
                Email              = applicationDto.Email,
                UserName           = applicationDto.Email,
                NormalizedUserName = applicationDto.Email,
                EmailConfirmed     = false
            };

            newUser.PasswordHash = new PasswordHasher <IdentityUser>().HashPassword(newUser, RandomString(40));

            var newCoreUser = CoreUser.Create(Guid.Parse(newUser.Id));

            newCoreUser.Update(new CoreUserDto()
            {
                Access  = AccessEnum.Standard,
                Picture = @"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAALCElEQVR4nO2de4xdRR3HP3e726W1ltLHFulSxGKpbiltkWKppUskRlQkolQBBRUBFaP4QqIxSJrGBDEoKOIDMUaDmhBFUeujGOqDtljbWkqF9AWtYruVdvug3e7dXf/43d3unvM7e8+599x53J1PMoFM957zPTNzzvzmN7+ZgcCIpmBbgEHGAK3ANOBkYBTQWPq3HqAIHAF2A7tK/1/31GsDKAALgSXAAuB8pOKzsAf4O7AGWAX8BWkoAYe5ALgfeAHoyzl1AA8C7aYeJpCOAvBuYDX5V3pS2gBch3QjAYssAp7EXMVH00Y8/yL4agOMBb4G3JDhN92Igbcb+Zz3AL2lfysgb/MUxFBsBUZnuPYPgZuBwxl+E6iQNmAz5d/Ow8DDwI3AfKApwz2agHlIA3u4dK1y93u2dJ9ADWkHOhm+Ip5AbIKTcrzvGOAqZEQw3L2PAJfmeN/AIC4HjpFc+E8CFxnQ0Q6sG0bHcaSxBHJkMdBF8qf+BszaMw3AR4CXEjR1A280qKeumQHsQy/oTcAse9JoA7YouvqA/cDZ9qTVB03ImFsr4McRl65tJpFsG2wi22giEGEZyZWfp5FXLeOAtehal1nU5TXnIn2pNtyaaFFXEqcCz6PbA3Ms6vKW3xAvzC5gtk1RZTgfmVWM6v6VTVE+shD9c/p5m6JS8mV07RfYFOUbjxIvwH9xYv7eZZqB54jrf8SmKJ84HfHTRwvQJ+fKjcT1F4FX2BTlC7ejG34NNkVlpAmJKoo+x+dsivIFzbFym1VFlbGc+HOst6rIA04nXmg9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onBkPVrqW8gddvtEwzJaqOmYaU5R6GL/O9GNiS5qYyInYAHybsjFULmhE74XmSy/8Y1S+GSeRKkq3VY4hr1+tFEp4wGriD5JHNIWRtQ67MJ/mz/wzwmrxvGCjLHGQqXKuTDnLsfsei74HXh8zihcgXe7QgaxW0ullJTjES9ybcYA3Vee4C+XAyEsWs1dGnq734LPSp0B3ApGovHsiNqcg6hmg9dVJl8MnPlYsWCTtgusjF6Eb63ZVe8GzlYn3AXdUqDdSMe9BHaBV9re9ULrYfv87vG2lMRp9uviXrhUYhESrRC92Rl9JAzVhOvN6eynqRBcpFepDl1wG3ORM9+kgNTUsaJ7YreasQN2TAbXYAf1by27U/TmoAS5S8xyoUFDDPSiWvPcsFtJmni6qWFTDFEuL1tyXtj09TftxL8Pr5xMuJ2wFFlGAcrQuYq+RtQxY7BPzgEDJRNJhRKGF7WgOYp+RtyEFUwCxancWCSdN+AUID8I+KG0D4AtQHWp1pL/cQxqM7EUJsn3+0Eq/Hg5RZCrBY+VFHTWUGakkHZTyC0S5A+/xvrIm0gAm0uhtiB0QbQDAA6wutAQyp4zRfgNAA/CXVSKCfJvTI39k1kRYwwTnE63Nn0h/PVf74KGFnK59pRCKCovU6sNHm4C5A6/83Iz7kgJ8UkTqMMtANDG4Aof+vT4Z1CA3+vGsNYAGyIUHAX7SNtAa+AIVB/z2AeAID9c8/kB3bBhrADGRXjMDIoAuJ7yj22wBlJwkCdUUzsuprwAjU+v9AfTMXTnQBs5B9/QIjh+2EKO/A/wHsftbNgz/GngAAAABJRU5ErkJggg=="
            });

            _readWriteRepository.Create <CoreUser, Guid>(newCoreUser);

            var application = Application.Create(Guid.Parse(newUser.Id), 1);

            var preliminaryDto = new ApplicationDto()
            {
                UserId      = Guid.Parse(newUser.Id),
                Name        = applicationDto.Name,
                Status      = StatusEnum.Preliminary,
                DateOfBirth = applicationDto.DateOfBirth,
                State       = applicationDto.State,
                Country     = applicationDto.Country,
                //Hold over variables
                PhoneNo        = application.PhoneNo,
                RegistrationNo = application.RegistrationNo
            };

            application.Update(preliminaryDto);

            _readWriteRepository.Create <Application, int>(application);

            await _users.CreateAsync(newUser, default(CancellationToken));

            return(Ok());
        }
Exemple #13
0
        /// <summary>
        /// Get user claim
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        private IList <Claim> GetUserClaims(CoreUser user)
        {
            // User Claims
            var claims = new List <Claim>
            {
                new Claim(Common.Constants.JwtConstants.ClaimIdentifiers.Id, user.Id.ToString())
            };

            // Role Claims
            claims.AddRange(this.GetRoleClaims(user));

            return(claims);
        }
        private IEnumerable <Claim> GetUserRoleClaims(CoreUser user)
        {
            List <Claim> claims = new List <Claim>();
            var          roles  = _userDm.GeRolesByUserId(user.Id).ToList();

            foreach (var role in roles)
            {
                claims.Add(new Claim(ClaimTypes.Role, role.Code));
                claims.AddRange(this.GetUserPermissionClaims(role));
            }

            return(claims);
        }
Exemple #15
0
        /// <summary>
        /// Method to get Core User Object by User ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Core User</returns>

        public async Task <CoreUser> GetUserById(long id)
        {
            var dbUser = await _userRepository.GetUserByUserId(id);

            if (dbUser == null)
            {
                throw new Exception("User does not exist");
            }

            CoreUser coreUser = EfUserMapper.DbToCoreUser(dbUser);

            return(coreUser);
        }
        public async Task SetAsync(IEnumerable <GuildMember> entries, string?parent = null)
        {
            var users   = new List <CoreUser>();
            var members = new List <CoreGuildMember>();

            foreach (var entry in entries)
            {
                users.Add(CoreUser.From(Context.Client, entry.User));
                members.Add(CoreGuildMember.From(Context.Client, entry));
            }

            await Task.WhenAll(Context.Users.SetAsync(users), SetAsync(members, parent));
        }
Exemple #17
0
 public DealsServiceTests()
 {
     mockUser = new CoreUser
     {
         UserId              = "b9dd9a67-dcc5-437a-a9e3-335bfdfc456a",
         OrgId               = 168,
         IsTestMode          = true,
         IsGlobalPermissions = false,
         OrgAdmin            = false,
         StcAdmin            = false,
         WsAdmin             = false,
         IsManager           = false,
     };
 }
Exemple #18
0
        private async Task <UserDto> GetUserDto(CoreUser coreUser)
        {
            var identityUser = await _users.FindByIdAsync(coreUser.Id.ToString(), new CancellationToken());

            return(new UserDto()
            {
                Id = coreUser.Id,
                UserName = identityUser.UserName,
                Email = identityUser.Email,
                EmailConfirmed = identityUser.EmailConfirmed,
                TwoFactorEnabled = identityUser.EmailConfirmed,
                AccessFailedCount = identityUser.AccessFailedCount,
                CoreUser = _mapper.Map <CoreUserDto>(coreUser)
            });
        }
Exemple #19
0
        public int UpdateUser(UserModel user)
        {
            CoreUser userCore = new CoreUser();

            userCore.Name     = user.Name;
            userCore.Email    = user.Email;
            userCore.Password = user.Password;
            userCore.UserName = user.UserName;
            userCore.RoleId   = user.RoleId;
            userCore.id       = user.id;

            int userId = _userManager.UpdateUser(userCore);

            return(userId);
        }
Exemple #20
0
        /// <summary>
        /// Get role claim
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        private IList <Claim> GetRoleClaims(CoreUser user)
        {
            var claims = new List <Claim>();
            var roles  = _userDm.GeRolesByUserId(user.Id).ToList();

            foreach (var role in roles)
            {
                claims.Add(new Claim(Common.Constants.JwtConstants.ClaimIdentifiers.Roles, role.Code));
            }

            // Module Claims
            claims.AddRange(this.GetModuleClaims(roles));

            return(claims);
        }
Exemple #21
0
 public ContainerAlertsServiceTests()
 {
     // The default mock user
     mockUser = new CoreUser
     {
         UserId              = "b9dd9a67-dcc5-437a-a9e3-335bfdfc456a",
         OrgId               = 168,
         IsTestMode          = true,
         IsGlobalPermissions = false,
         OrgAdmin            = false,
         StcAdmin            = false,
         WsAdmin             = false,
         IsManager           = false,
     };
 }
Exemple #22
0
        public async Task SeedAsync()
        {
            _context.Database.EnsureCreated();

            CoreUser user = await _userManager.FindByEmailAsync("*****@*****.**");

            if (user == null)
            {
                user = new CoreUser()
                {
                    FirstName = "Puru",
                    LastName  = "Dangol",
                    Email     = "*****@*****.**",
                    UserName  = "******"
                };
                var result = await _userManager.CreateAsync(user, "P@ssw0rd!");

                if (result != IdentityResult.Success)
                {
                    throw new InvalidOperationException("Could not create new user in seeder.");
                }
            }

            if (!_context.Products.Any())
            {
                var filePath = Path.Combine(_hosting.ContentRootPath, "Data/art.json");
                var json     = File.ReadAllText(filePath);
                var products = JsonConvert.DeserializeObject <IEnumerable <Product> >(json);
                _context.Products.AddRange(products);

                var order = _context.Orders.Where(o => o.Id == 1).FirstOrDefault();
                if (order != null)
                {
                    order.User  = user;
                    order.Items = new List <OrderItem>()
                    {
                        new OrderItem()
                        {
                            Product   = products.First(),
                            Quantity  = 5,
                            UnitPrice = products.First().Price
                        }
                    };
                }

                _context.SaveChanges();
            }
        }
Exemple #23
0
        /// <summary>
        /// Method to pull user object by email
        /// </summary>
        /// <param name="email"></param>
        /// <returns>Core User</returns>
        public async Task <CoreUser> GetUserByEmail(string email)
        {
            //pull user object
            var dbUser = await _userRepository.GetUserByEmail(email);

            //validate user exists
            if (dbUser == null)
            {
                throw new Exception("User does not exist");
            }

            //map db user to core user
            CoreUser coreUser = EfUserMapper.DbToCoreUser(dbUser);

            return(coreUser);
        }
Exemple #24
0
        public async Task <ActionResult> UpdateUser(CoreUser user, int id)
        {
            try
            {
                var result = _context.CoreUser.Find(id);
                result = user;
                _context.CoreUser.Update(result);
                await _context.SaveChangesAsync();

                return(Ok($"Updated record {user.Id} successfully."));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #25
0
    protected void B_Login_Click(object sender, EventArgs e)
    {
        if (validarNumeros(TB_Cedula.Text) == true)
        {
            MAC a = new MAC();

            UUsuario user = new UUsuario();
            user.Usuario = TB_Cedula.Text.ToString();
            user.Clave   = TB_Clave.Text.ToString();
            user.Ip      = HttpContext.Current.Request.UserHostAddress;
            user.Mac     = a.traerMac();

            DAOUsuario guardarUsuario = new DAOUsuario();
            DataTable  data           = guardarUsuario.loggin(user.Usuario, user.Clave);

            user = new CoreUser().autenticar(user);


            Session["clave"]      = user.Clave;
            Session["user_id"]    = user.Usuario;
            Session["nombre_rol"] = user.Nombre_rol;
            Session["rol_id"]     = user.Rol_id;
            Session["nombre"]     = user.Nombre;
            Session["sede"]       = user.Sede;

            Response.Write("<script>window.alert('" + user.Mensaje + "');</script>");

            if (user.Rol_id == 1)
            {
                Response.Redirect("~/View/Tienda/AgregarSede.aspx");
            }

            if (user.Rol_id == 2)
            {
                Response.Redirect("~/View/Tienda/CRUDVendedor.aspx");
            }

            if (user.Rol_id == 3)
            {
                Response.Redirect("~/View/Tienda/CRUDCliente.aspx");
            }
        }
    }
Exemple #26
0
        public async Task <ActionResult> NewUser(CoreUser user)
        {
            try
            {
                foreach (var item in user.Account)
                {
                    item.HashedPassword = AuthUtilities.HashPassword(user.TempPassword);
                }

                _context.CoreUser.Add(user);
                await _context.SaveChangesAsync();

                return(Ok("User Saved!"));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Exemple #27
0
        public async Task <IActionResult> Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await userManager.FindByNameAsync(model.UserName);

                if (user == null)
                {
                    user = new CoreUser()
                    {
                        Id       = Guid.NewGuid().ToString(),
                        UserName = model.UserName
                    };

                    var result = await userManager.CreateAsync(user, model.Password);
                }

                return(View("Success"));
            }

            return(View());
        }
        public IActionResult GetToken(User postuser)
        {
            var response = ResponseModelFactory.CreateInstance;
            var userInfo = new CoreUser
            {
                LoginName = postuser.userName,
                Password  = postuser.password
            };
            var user = _userAppService.GetUser(userInfo.LoginName);

            if (user != null)
            {
                Dictionary <string, string> clims = new Dictionary <string, string>();
                clims.Add("userId", user.Id.ToString());
                clims.Add("username", user.DisplayName);
                //写入缓存
                _redis.Set(user.Id, user);
                response.SetData(_jwt.GetToken(clims));
                return(Ok(response));
            }
            response.SetError();
            return(Ok(response));
        }
Exemple #29
0
    protected void B_Login_Click(object sender, EventArgs e)
    {
        Loguearse log  = new Loguearse();
        UUsuario  user = new UUsuario();

        user = log.loguear(TB_Cedula.Text.ToString(), TB_Clave.Text.ToString());

        DAOUsuario guardarUsuario = new DAOUsuario();
        DataTable  data           = guardarUsuario.loggin(user);

        user = new CoreUser().autenticar(user);

        Session["clave"]      = user.Clave;
        Session["user_id"]    = user.Usuario;
        Session["nombre_rol"] = user.Nombre_rol;
        Session["rol_id"]     = user.Rol_id;
        Session["nombre"]     = user.Nombre;
        Session["sede"]       = user.Sede;
        pintar(user);
        Validaciones validarRol = new Validaciones();

        Response.Redirect(validarRol.validarRol(user.Rol_id));
    }
Exemple #30
0
        private void txtEmployeeID_Leave(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtEmployeeID.Text.TrimEnd()))
            {
                btnCreate.Text = "&Create";

                nsgEmployee = DB.NSGEmployees.Where(emp => emp.NSGEmployeeCode == txtEmployeeID.Text).FirstOrDefault();

                if (nsgEmployee != null)
                {
                    btnCreate.Text = "&Update";

                    txtFirstName.Text = nsgEmployee.FirstName;
                    txtLastName.Text  = nsgEmployee.LastName;
                    if (nsgEmployee.Gender.ToUpper() == "MALE")
                    {
                        radMale.Checked = true;
                    }
                    else
                    {
                        radFemale.Checked = true;
                    }
                    cmbRank.SelectedValue        = nsgEmployee.RankID;
                    cmbUnit.SelectedValue        = nsgEmployee.UnitID;
                    cmbQuarterType.SelectedValue = nsgEmployee.QuarterTypeID;
                    txtQuarterNumber.Text        = nsgEmployee.QuarterNumber.ToString();

                    coreUser = DB.CoreUsers.Where(cu => cu.EmployeeID.ToString() == txtEmployeeID.Text).FirstOrDefault();

                    if (coreUser != null)
                    {
                        txtUserName.Text = coreUser.UserName;
                    }
                }
            }
        }