Exemplo n.º 1
0
        public ValidUserContext ValidUser(string userName, string password)
        {
            var validUserContext = new ValidUserContext();
            var user             = _userRepository.GetSingleByUserName(userName);

            if (user != null && !isUserIsLocked(user, password))
            {
                var userRoles = GetUserRoles(user.Key);
                validUserContext.User = new UserWithRoles()
                {
                    User  = user,
                    Roles = userRoles
                };
                var identity = new GenericIdentity(user.Name);
                validUserContext.Principal = new GenericPrincipal(identity, userRoles.Select(t => t.Name).ToArray());
            }
            return(validUserContext);
        }
Exemplo n.º 2
0
        public ValidUserContext ValidateUser(string username, string password) {

            var userCtx = new ValidUserContext();
            var user = _userRepository.GetSingleByUsername(username);
            if (user != null && isUserValid(user, password)) {

                var userRoles = GetUserRoles(user.Key);
                userCtx.User = new UserWithRoles() {
                    User = user, Roles = userRoles
                };

                var identity = new GenericIdentity(user.Name);
                userCtx.Principal = new GenericPrincipal(
                    identity,
                    userRoles.Select(x => x.Name).ToArray());
            }

            return userCtx;
        }
Exemplo n.º 3
0
        public ValidUserContext ValidateUser(string username, string password)
        {
            var userCtx = new ValidUserContext();
            var user    = _userRepository.GetSingleByUsername(username);

            if (user != null && isUserValid(user, password))
            {
                var userRoles = GetUserRoles(user.Key);
                userCtx.User = new UserWithRoles()
                {
                    User  = user,
                    Roles = userRoles
                };
                var identity = new GenericIdentity(user.Name);
                userCtx.Principal = new GenericPrincipal(
                    identity,
                    userRoles.Select(x => x.Name).ToArray());
            }
            return(userCtx);
        }