BCR.UserDatabase.GetUserFromApiKey C# (CSharp) Method

GetUserFromApiKey() public static method

public static GetUserFromApiKey ( string apiKey ) : IUserIdentity
apiKey string
return IUserIdentity
        public static IUserIdentity GetUserFromApiKey(string apiKey)
        {
            if (apiKey == null)
            return null;

              BCRUser user;
              if (users.TryGetValue(apiKey, out user))
            return user;

              NameValueCollection result = Database.Instance.QuerySingle("SELECT user.id as id, username, apikey, fullname FROM user JOIN user_apikeys ON user.id=user_apikeys.user_id WHERE apikey = '" + apiKey + "' LIMIT 1;");
              if (result == null)
            return null;

              user = new BCRUser { UserName = result["username"], UserId = Convert.ToInt32(result["id"]), FullName = result["fullname"] };
              user.Initialize();

              lock (lockObject)
              {
            users[apiKey] = user;
              }

              return user;
        }