Ejemplo n.º 1
0
        public override User Modify(User model)
        {
            User currentRole = Get(model.UserId);

            UpdateRoles(currentRole, model);

            if (!string.IsNullOrEmpty(model.Password))
            {
                model.Password = EncriptionUtils.HashValueToString(model.Password, model.IdentificationNumber);
            }

            Repository.Db.Entry(currentRole).CurrentValues.SetValues(model);
            Repository.SaveChanges();
            return(model);
        }
Ejemplo n.º 2
0
        private UserProfile AuthenticateWithPassword(string password, User user)
        {
            if (user.Password != EncriptionUtils.HashValueToString(password, user.IdentificationNumber))
            {
                throw new AuthorizationExeption(AuthorizationError.InvalidCredentials, "Invalid user name or password!");
            }

            var token = new UserToken
            {
                Token     = Guid.NewGuid().ToString("N"),
                UserId    = user.UserId,
                CreatedAt = DateTime.Now,
                DueDate   = DateTime.Now.AddHours(1)
            };

            Repository.Db.Set <UserToken>().Add(token);
            Repository.SaveChanges();

            return(ToUserProfile(user, token));
        }
Ejemplo n.º 3
0
 public override User Add(User model)
 {
     model.Password = EncriptionUtils.HashValueToString(model.Password, model.IdentificationNumber);
     return(base.Add(model));
 }