示例#1
0
 public WebWorkContext(HttpContextBase httpContext, IUserService userService, IUserAgentHelper userAgentHelper,
     IAuthenticationService authenticationService, User cachedUser)
 {
     _httpContext = httpContext;
     _userService = userService;
     _userAgentHelper = userAgentHelper;
     _authenticationService = authenticationService;
     _cachedUser = cachedUser;
 }
 public UserRegistrationRequest(User user, string email, string username, string password,
     bool isApproved = true)
 {
     User = user;
     Email = email;
     Username = username;
     Password = password;
     IsApproved = isApproved;
 }
示例#3
0
        private static void FilteredLog(ILogger logger, LogLevel level, string message, Exception exception = null,
            User user = null)
        {
            //No se guarda el registro cuando es de un hilo de una excepcion de abort
            if (exception is ThreadAbortException)
                return;

            if (logger.IsEnabled(level))
            {
                var fullMessage = exception == null ? string.Empty : exception.ToString();
                logger.InsertLog(level, message, fullMessage, user);
            }
        }
示例#4
0
        public bool Authorize(string permissionRecordSystemName, User user)
        {
            if (String.IsNullOrEmpty(permissionRecordSystemName))
                return false;

            var customerRoles = user.UserRoles.Where(cr => cr.Active);
            foreach (var role in customerRoles)
                if (Authorize(permissionRecordSystemName, role))
                    return true; //Hay permiso

            //No se encontro permiso
            return false;
        }
示例#5
0
        public bool Authorize(PermissionRecord permission, User user)
        {
            if (permission == null)
                return false;

            if (user == null)
                return false;

            return Authorize(permission.SystemName, user);
        }
        public void SetUsername(User user, string newUsername)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            newUsername = newUsername.Trim();

            if (newUsername.Length > 100)
                throw new KsException("Nombre de usuario es demasiado largo");

            var user2 = _userService.GetUserByUserName(newUsername);
            if (user2 != null && user.Id != user2.Id)
                throw new KsException("El nombre de usuario ya esta en uso");

            user.UserName = newUsername;
            _userService.UpdateUser(user);
        }
        public void SetEmail(User user, string newEmail)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            newEmail = newEmail.Trim();

            if (!CommonHelper.IsValidEmail(newEmail))

                if (newEmail.Length > 100)
                    throw new KsException("El email es demasiado largo");

            var user2 = _userService.GetUserByEmail(newEmail);
            if (user2 != null && user.Id != user2.Id)
                throw new KsException("El email ya está en uso");

            user.Email = newEmail;
            _userService.UpdateUser(user);

        }
示例#8
0
 public virtual TimeZoneInfo GetUserTimeZone(User user)
 {
     return DefaultStoreTimeZone;
 }
示例#9
0
 public static void Debug(this ILogger logger, string message, Exception exception = null,
     User user = null)
 {
     FilteredLog(logger, LogLevel.Debug, message, exception, user);
 }
示例#10
0
        public virtual void DeleteUser(User user)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            if (user.IsSystemAccount)
                throw new KsException(string.Format("System user account ({0}) could not be deleted", user.SystemName));

            user.Deleted = true;
            user.Active = false;

            if (!String.IsNullOrEmpty(user.Email))
                user.Email += "-DELETED";
            if (!String.IsNullOrEmpty(user.UserName))
                user.UserName += "-DELETED";
            UpdateUser(user);
        }
示例#11
0
        public virtual void UpdateUser(User user)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            _userRepository.Update(user);
        }
示例#12
0
        public virtual void InsertUser(User user)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            _userRepository.Insert(user);
        }