Beispiel #1
0
        /// <summary>
        /// add token to blacklist
        /// </summary>
        /// <returns>isSuccessful = true is added else false</returns>
        public Outcome Execute()
        {
            var response = new Outcome();

            LoginDTO loginDTO = new LoginDTO()
            {
                UserName = userCredentia.Username,
                Token    = userCredentia.Token
            };

            LoginGateway logoutGateway = new LoginGateway();

            response.Result = logoutGateway.AddTokenToBlackList(loginDTO);

            return(response);
        }
        /// <summary>
        /// refreshes token
        /// </summary>
        /// <returns>new token</returns>
        public TokenRefreshResponseDTO RefreshService()
        {
            LoginGateway gateway = new LoginGateway();

            LoginDTO incUsername = new LoginDTO()
            {
                UserName = username,
                Token    = response.token
            };


            response.Messages = new List <string>();

            var storetoken = gateway.AddTokenToBlackList(incUsername);


            if (storetoken.isSuccessful == false)
            {
                response.Messages.Add("Failed to add token");
                return(response);
            }

            CreateJWT newJWT = new CreateJWT();

            var jwt = newJWT.CreateToken(username);

            if (jwt == "Failed")
            {
                response.Messages.Add("Failed To make token");
                return(response);
            }

            response.token        = jwt;
            response.username     = this.username;
            response.isSuccessful = true;
            response.Messages.Add("Success!");

            return(response);
        }