<commit_before>﻿using System;
using System.Collections.Generic;
using Microsoft.Owin;

namespace Hangfire.Dashboard
{
    public class ClaimsBasedAuthorizationFilter : IAuthorizationFilter
    {
        private readonly string _type;
        private readonly string _value;

        public ClaimsBasedAuthorizationFilter(string type, string value)
        {
            if (type == null) throw new ArgumentNullException("type");
            if (value == null) throw new ArgumentNullException("value");

            _type = type;
            _value = value;
        }

        public bool Authorize(IDictionary<string, object> owinEnvironment)
        {
            var context = new OwinContext(owinEnvironment);
            return context.Authentication.User.HasClaim(_type, _value);
        }
    }
}<commit_msg>User might be null<commit_after>﻿using System;
using System.Collections.Generic;
using Microsoft.Owin;

namespace Hangfire.Dashboard
{
    public class ClaimsBasedAuthorizationFilter : IAuthorizationFilter
    {
        private readonly string _type;
        private readonly string _value;

        public ClaimsBasedAuthorizationFilter(string type, string value)
        {
            if (type == null) throw new ArgumentNullException("type");
            if (value == null) throw new ArgumentNullException("value");

            _type = type;
            _value = value;
        }

        public bool Authorize(IDictionary<string, object> owinEnvironment)
        {
            var context = new OwinContext(owinEnvironment);
            
            if (context.Authentication.User == null)
                return false;
                
            return context.Authentication.User.HasClaim(_type, _value);
        }
    }
}
{'fraction_non_alphanumeric': 0.07617411225658649, 'fraction_numerical': 0.0, 'mean_word_length': 2.3596153846153847, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2561078', 'n_tokens_mistral': 430, 'n_tokens_neox': 419, 'n_words': 114}