Ejemplo n.º 1
0
        private static bool IsGeolocationProfileMeet(NotNullNameValuePairs profile, Member user)
        {
            if (profile.Count > 0 && !String.IsNullOrEmpty(profile.Keys.First <string>()))
            {
                foreach (var pair in profile)
                {
                    if (!string.IsNullOrEmpty(pair.Key))
                    {
                        bool exists = false;
                        foreach (var custom in user.Custom)
                        {
                            if (pair.Key == custom.Key)
                            {
                                exists = true;
                                if (GeolocationNumber.IsGeolocationNumber(pair.Value) && !GeolocationNumber.Parse(pair.Value).IsBetweenMinAndMax(Convert.ToInt32(custom.Value)))
                                {
                                    return(false);
                                }
                                else if (!GeolocationNumber.IsGeolocationNumber(pair.Value) && pair.Value != custom.Value)
                                {
                                    return(false);
                                }
                            }
                        }

                        if (exists == false)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public static void GetTokenAndLogin(string code, string state)
        {
            if (HttpContext.Current.Session != null && HttpContext.Current.Session[SessionStateKey] != null &&
                HttpContext.Current.Session[SessionStateKey].ToString() != state)
            {
                throw new Exception("Invalid OAuth state.");
            }

            string accessToken =
                OAuth2.AuthenticateByCode(GetProvider(state), HandlerUrl, code).AccessToken;

            string userInfoString = OAuth2.GetUserInfo(GetProvider(state), accessToken);

            JObject UserInfo   = JObject.Parse(userInfoString);
            JToken  UserObject = UserInfo["userObj"];

            string username = UserObject["id"].ToString();

            if (!Member.Exists(username))
            {
                //Register

                string   email     = UserObject["email"].ToString();
                DateTime birthYear = new DateTime((int)UserObject["birth"]["year"], 1, 1);

                TitanRegisterService.Register(username, email, 1234, birthYear,
                                              HashingManager.GenerateMD5(DateTime.Now + username), String.Empty, Gender.Male, null, String.Empty,
                                              String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, true, false, false, null, true);
            }

            Member member = new Member(username);

            member = MemberAuthenticationService.CreateAuthCredentials(member);

            member.BirthYear  = new DateTime((int)UserObject["birth"]["year"], 1, 1);
            member.FirstName  = UserObject["first_name"].ToString();
            member.SecondName = UserObject["last_name"].ToString();
            member.AvatarUrl  = UserObject["avatar_url"].ToString();

            NotNullNameValuePairs nvp = new NotNullNameValuePairs();

            nvp.Add("adzbuzz_affid", UserObject["affid"].ToString());
            nvp.Add("adzbuzz_userid", UserObject["id"].ToString());

            member.Custom = nvp;

            member.Save();

            TitanAuthService.AuthenticateWithChecks(member, false, true);
        }
Ejemplo n.º 3
0
    public static void Save(Member User, Panel page, bool isFromSurvey = false)
    {
        if (!AppSettings.Authentication.CustomFieldsAsSurvey || isFromSurvey)
        {
            var Fields = TableHelper.SelectRows <Titan.CustomRegistrationField>(TableHelper.MakeDictionary("IsHidden", false));
            NotNullNameValuePairs nvp = new NotNullNameValuePairs();

            foreach (var Field in Fields)
            {
                if (Field.Type == RegistrationFieldType.TextBox)
                {
                    nvp.Add(Field.StringID, ((TextBox)page.FindControl(customFieldPrefix + Field.StringID)).Text);
                }
                else if (Field.Type == RegistrationFieldType.CheckBox)
                {
                    nvp.Add(Field.StringID, ((CheckBox)page.FindControl(customFieldPrefix + Field.StringID)).Checked.ToString());
                }
            }
            User.Custom = nvp;
        }
    }
Ejemplo n.º 4
0
 public GeolocationUnit()
 {
     Profile = new NotNullNameValuePairs();
     MinAge  = 0; MaxAge = 0; Gender = Gender.Null;
 }