Esempio n. 1
0
        public static T GetService <T>(RequestContext Request) where T : class
        {
            string Token       = string.Empty;
            var    SessionAuth = Request.HttpContext.Session[GlobalParams.UserSessionKey];
            var    TokenType   = SVC.DTO.TokenType.WebAuth;

            if (SessionAuth != null)
            {
                var AuthObject = (AuthResponse)SessionAuth;
                Token = AuthObject.Token;
            }

            if (typeof(T) == typeof(IAuthService))
            {
                return((T)ServiceFinder.GetAuthService());
            }
            else if (typeof(T) == typeof(IContentService))
            {
                return((T)ServiceFinder.GetContentService(Token, TokenType, Request.HttpContext.Server.MapPath("~/Uploads/")));
            }
            else if (typeof(T) == typeof(IUserService))
            {
                return((T)ServiceFinder.GetUserService(Token, TokenType));
            }
            else if (typeof(T) == typeof(IGroupService))
            {
                return((T)ServiceFinder.GetGroupService(Token, TokenType));
            }
            else if (typeof(T) == typeof(IGenreService))
            {
                return((T)ServiceFinder.GetGenreService(Token, TokenType));
            }

            return(null);
        }
Esempio n. 2
0
        public void AuthUserTest()
        {
            var AuthService = ServiceFinder.GetAuthService();

            Assert.IsFalse(AuthService.AuthUser(MockEmail, "", SVC.DTO.TokenType.WebAuth).IsSuccess);
            Assert.IsFalse(AuthService.AuthUser(MockEmail, "h" + MockPassword, TokenType.WebAuth).IsSuccess);
            Assert.IsTrue(AuthService.AuthUser(MockEmail, MockPassword, TokenType.WebAuth).IsSuccess);
        }
Esempio n. 3
0
        public void GetAuthResponseTest()
        {
            var TokenService = ServiceFinder.GetTokenService();
            var AuthService  = ServiceFinder.GetAuthService();
            var CodeToken    = TokenService.CreateToken(TokenType.WebAuth, 1);
            var Auth         = AuthService.GetAuthResponse(CodeToken, TokenType.WebAuth);

            Assert.IsTrue(Auth.Token.Length == 32);
            Assert.IsFalse(string.IsNullOrEmpty(Auth.Name));
            Assert.IsFalse(string.IsNullOrEmpty(Auth.Email));
        }
Esempio n. 4
0
        public void AuthUserTestEmpty()
        {
            var AuthService = ServiceFinder.GetAuthService();

            Assert.IsFalse(AuthService.AuthUser("", "", SVC.DTO.TokenType.WebAuth).IsSuccess);
        }