예제 #1
0
        public async Task <IHttpActionResult> DeleteToken(string username, Guid tokenId)
        {
            User user;

            user = Database.PlayerData.User.Find(username);

            if (user == null)
            {
                return(Unauthorized());
            }

            var refreshToken = RefreshToken.FindForUser(user).FirstOrDefault();

            if (refreshToken?.Id != tokenId)
            {
                return(Unauthorized());
            }

            if (RefreshToken.Remove(refreshToken, true))
            {
                return(Ok(
                           new
                {
                    username,
                    tokenId
                }
                           ));
            }

            return(StatusCode(HttpStatusCode.Gone));
        }