Beispiel #1
0
    protected override ApiResultMessage HandleRequest(object args)
    {
        var    data = ((JObject)args).ToObject <ApiAuthenticationData>();
        Member user = null;

        if (!data.isFacebook)
        {
            //Standard login procedure
            TitanAuthService.Login(data.username, data.password, data.secondaryPassword, false);
            user = new Member(data.username);
        }
        else
        {
            //Facebook login procedure
            FacebookMember fbUser = new FacebookMember(data.username);
            TitanAuthService.LoginOrRegister(fbUser, false);
            user = TableHelper.SelectRows <Member>(TableHelper.MakeDictionary("FacebookOAuthId", fbUser.FacebookId))[0];
        }

        var token = ApiAccessToken.GetOrCreate(user.Id);

        return(new ApiResultMessage
        {
            success = true,
            message = String.Empty,
            data = new JObject(new JProperty("token", token.Token))
        });
    }
Beispiel #2
0
    private static bool HasUserMeetRequirements(FacebookAdvert Ad, FacebookMember FbMember)
    {
        bool IsOKWithRequirements = true;

        //Profile pic
        if (Ad.HasProfilePicRestrictions && !FbMember.HasProfilePicture)
        {
            IsOKWithRequirements = false;
        }

        //Friends
        if (Ad.MinFriends > 0 && FbMember.Friends < Ad.MinFriends)
        {
            IsOKWithRequirements = false;
        }

        return(IsOKWithRequirements);
    }
Beispiel #3
0
    protected void CreateUserButton_Click(object sender, EventArgs e)
    {
        ErrorMessagePanel.Visible = false;

        if (Page.IsValid)
        {
            try
            {
                DateTime InBirthYear  = new DateTime(Int32.Parse(BirthYear.Text.Trim()), 1, 1);
                Gender   InGender     = GenderList.SelectedValue == "1" ? Gender.Male : Gender.Female;
                Panel    CustomFields = this.CustomFields;
                int      InPIN        = AppSettings.Registration.IsPINEnabled ? Int32.Parse(PIN.Text.Trim()) : 9999;

                if (IsFromFacebookOAuth)
                {
                    //Facebook register procedure
                    string accessToken = Session["accessToken"].ToString();

                    FacebookMember fbMember = new FacebookMember(accessToken);
                    TitanRegisterService.Register(Username.Text.Trim(), Email.Text.Trim(), InPIN, InBirthYear, accessToken,
                                                  Referer.Text.Trim(), fbMember.Gender, CustomFields, FirstName.Text, SecondName.Text, Address.Text,
                                                  City.Text, StateProvince.Text, ZipCode.Text, EarnerCheckBox.Checked, AdvertiserCheckBox.Checked,
                                                  PublisherCheckBox.Checked, fbMember.FacebookId);
                }
                else
                {
                    //Standard register procedure
                    TitanRegisterService.Register(Username.Text.Trim(), Email.Text.Trim(), InPIN, InBirthYear, Password.Text.Trim(),
                                                  Referer.Text.Trim(), InGender, CustomFields, FirstName.Text, SecondName.Text, Address.Text, City.Text,
                                                  StateProvince.Text, ZipCode.Text, EarnerCheckBox.Checked, AdvertiserCheckBox.Checked, PublisherCheckBox.Checked);
                }
            }
            catch (MsgException ex)
            {
                ErrorMessagePanel.Visible = true;
                ErrorMessage.Text         = ex.Message;
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                throw ex;
            }
        }
    }
Beispiel #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.EarnersRoleEnabled && AppSettings.TitanFeatures.EarnLikesEnabled && Member.CurrentInCache.IsEarner);
        DisplayMessage();

        LabelInfo.Text = L1.CONNECTWITHFACEBOOK;
        User           = Member.CurrentInCache;

        //Get codes
        BodyCode = FacebookMember.GetJSStartingCode();

        if (FacebookMember.Logged() != null)
        {
            LabelInfo.Text = L1.YOUCONNECTEDWITHFACEBOOK;
            FbUser         = new FacebookMember(FacebookMember.Logged());

            //Facebook security (banning multiple accounts instantly)
            User.FacebookName = FbUser.Name;
            User.Save();

            AntiCheatSystem.AfterFacebookLogin(User);
            FacebookLikesGridView.Visible = MyFriendsPlaceHolder.Visible = true;
            FacebookLoginPanel.Visible    = false;
        }
        else
        {
            FacebookLikesGridView.Visible = MyFriendsPlaceHolder.Visible = false;
        }

        FacebookLikesGridView.DataBind();

        if (AppSettings.Facebook.CustomFacebookLikesEnabled)
        {
            FacebookLikesGridView.Columns[4].HeaderText = U6012.REWARDFORLIKES;
            CustomLikesInfoLabel.Text = U6012.CUSTOMLIKESINFO;
        }
    }
Beispiel #5
0
    protected void FacebookLikesGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            FacebookAdvert Ad = new FacebookAdvert(Convert.ToInt32(e.Row.Cells[0].Text));

            //[2] Profile picture
            var check = (CheckBox)e.Row.Cells[2].Controls[0];
            if (check.Checked)
            {
                e.Row.Cells[2].Text = HtmlCreator.GetCheckboxCheckedImage();
            }
            else
            {
                e.Row.Cells[2].Text = HtmlCreator.GetCheckboxUncheckedImage();
            }

            //[3] Facebook like button
            e.Row.Cells[3].Text = FacebookMember.GetLikeButtonCode(Ad);

            if (FbUser != null && !User.AdsLiked.Contains(Ad.Id))
            {
                e.Row.Cells[1].Text += String.Format(" ({0} {1})", L1.YOUHAVE, FbUser.Friends);

                if (FbUser.Friends >= Ad.MinFriends)
                {
                    e.Row.Cells[1].ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    e.Row.Cells[1].ForeColor = System.Drawing.Color.DarkRed;
                }

                if (Ad.HasProfilePicRestrictions && !FbUser.HasProfilePicture)
                {
                    e.Row.Cells[2].Text      = L1.NEEDED.ToUpper();
                    e.Row.Cells[2].ForeColor = System.Drawing.Color.DarkRed;
                }
                else
                {
                    e.Row.Cells[2].Text      = "OK";
                    e.Row.Cells[2].ForeColor = System.Drawing.Color.Green;
                }
            }

            if (AppSettings.Facebook.CustomFacebookLikesEnabled)
            {
                //[4] Titan like button
                LinkButton btn = e.Row.FindControl("LikeButton") as LinkButton;
                if (FbUser != null && !User.AdsLiked.Contains(Ad.Id) && FbUser.Friends >= Ad.MinFriends && (!Ad.HasProfilePicRestrictions || Ad.HasProfilePicRestrictions && FbUser.HasProfilePicture))
                {
                    btn.ToolTip     = "Like";
                    btn.CommandName = "like";
                    btn.Text        = "<span class=\"fa fa-plus fa-lg text-success\"></span>";
                }
                else
                {
                    btn.ToolTip = "Forbidden";
                    btn.Text    = "<span class=\"fa fa-times fa-lg text-danger\"></span>";
                    btn.Enabled = false;
                }
            }
        }
    }
Beispiel #6
0
    public static string LikeUnlike(string adId, bool credit)
    {
        string succMsg = string.Empty;

        if (FacebookMember.Logged() != null)
        {
            Member         User = Member.Current;
            FacebookMember FbUser;
            FacebookAdvert Ad = new FacebookAdvert(Convert.ToInt32(adId));

            FbUser = new FacebookMember(FacebookMember.Logged());

            //Facebook security (banning multiple accounts instantly)
            User.FacebookName = FbUser.Name;
            User.Save();

            AntiCheatSystem.AfterFacebookLogin(User);

            if (FbUser == null)
            {
                return(U5008.MUSTCONNECTFB);
            }

            if (!HasUserMeetRequirements(Ad, FbUser))
            {
                return(L1.NOTMEETREQUIREMENTS);
            }

            var userLikes = User.FbLikesToday;
            var maxLikes  = User.Membership.MaxFacebookLikesPerDay;
            if (userLikes >= maxLikes)
            {
                return(string.Format(U6004.REACHEDMAXLIKESPERDAY, maxLikes));
            }

            HttpContext.Current.Session["fbcookie"] = "notok";

            if (credit)
            {
                Ad.Click();
                succMsg = U3501.YOUHAVEBEENCREDITED + " (" + AppSettings.Facebook.PointsPerLike + " " + AppSettings.PointsName + ")";
            }
            else
            {
                Ad.Unclick();
                succMsg = string.Format(U5008.POINTSREVERSED, AppSettings.Facebook.PointsPerLike + " " + AppSettings.PointsName);
            }

            if (Ad.ShouldBeFinished)
            {
                Ad.Status = AdvertStatus.Finished;
            }

            Ad.SaveClicks();
            Ad.Save();

            //Use Crediter
            FacebookCrediter Crediter = (FacebookCrediter)CrediterFactory.Acquire(User, CreditType.FacebookLike);
            Crediter.CreditMember(Ad, credit);

            NotificationManager.RefreshWithMember(NotificationType.NewFacebookAds, User);
            return(succMsg);
        }
        else
        {
            return(U5008.MUSTCONNECTFB);
        }
    }
Beispiel #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (AppSettings.Authentication.LoginUsingEmail)
        {
            Username.Attributes.Add("PlaceHolder", "Email");
        }
        else
        {
            Username.Attributes.Add("PlaceHolder", L1.USERNAME);
        }

        if (AppSettings.Authentication.ResetPasswordAndPinTogether)
        {
            ForgotMyPasswordHyperLink.Text = L1.IFORGOTPWD + "/PIN";
        }
        else
        {
            ForgotMyPasswordHyperLink.Text = L1.IFORGOTPWD;
        }

        //Facebook OAuth
        if (Request.QueryString["fb"] != null && Request["accessToken"] != null)
        {
            var accessToken = Request["accessToken"];
            Session["AccessToken"] = accessToken;
            try
            {
                FacebookMember User = new FacebookMember(accessToken);
                TitanAuthService.LoginOrRegister(User);
            }
            catch (MsgException ex)
            {
                FailureP.Visible = true;
                FailureText.Text = ex.Message;
                FormsAuthentication.SignOut();
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                throw ex;
            }
        }

        //Demo autofill
        if (AppSettings.IsDemo)
        {
            Username.Text = "demo";
            Password.Text = "demopassword";
            System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "document.getElementById('" + Password.ClientID + "').value = 'demopassword';", true);
        }

        //General autofill
        if (Request.QueryString["username"] != null && Request.QueryString["password"] != null)
        {
            string username = HttpUtility.UrlDecode(Request.QueryString["username"]);
            string password = HttpUtility.UrlDecode(Request.QueryString["password"]);

            Username.Text = username;
            Password.Text = password;

            System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "document.getElementById('" + Password.ClientID + "').value = '" + password + "';", true);
        }

        //Add label & hint translations
        HintAdder.Add(Password2, L1.LEAVEBLANKIFNOTPWD2);
        LangAdder.Add(LoginButton, U4000.LOGINTEXT);
        LangAdder.Add(CustomValidator1, L1.ER_BADCAPTCHA);
        LoginUserValidationSummary.HeaderText = L1.ER_ALLFIELDSREQUIRED;

        //Check wheather we should request Captcha (two bad logins trials)
        if (MemberAuthenticationService.GetBadLoginTrials(Context) > 1)
        {
            CaptchaPanel1.Visible = true;
            LoginUserValidationSummary.HeaderText = L1.ER_ALLFIELDSREQUIRED2;
        }

        if (Request.QueryString["afterregister"] != null && Convert.ToInt32(Request.QueryString["afterregister"]) == 1)
        {
            ShowResendActivationControls(true);
            ResendEmailButton.Visible = false;
        }
    }
Beispiel #8
0
 public static void LoginOrRegister(FacebookMember fbMember, bool redirect = true)
 {
     LoginOrRegister(fbMember.FacebookId, redirect);
 }
Beispiel #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GlobalMasterHelper.PageLoad();
        AdBlockManager.CheckDenyForAll();

        RegistrationCaptchaPlaceHolder.Visible = AppSettings.Registration.IsRegistrationCaptchaEnabled;
        PINSectionPlaceHolder.Visible          = AppSettings.Registration.IsPINEnabled;

        if (!Page.IsPostBack)
        {
            AppSettings.Authentication.Reload();

            if (Request.QueryString["e"] != null)
            {
                Email.Text = Request.QueryString["e"];
            }

            if (TitanFeatures.IsRetireYoung)
            {
                ReferrerUtils.SetReferrer("RetireYoung");
            }

            if (Request.QueryString["u"] != null || ReferrerUtils.GetReferrerName() != null)
            {
                string refUsername;
                if (Request.QueryString["u"] != null)
                {
                    ReferrerUtils.SetReferrer(Request.QueryString["u"]);
                }

                refUsername = ReferrerUtils.GetReferrerName();

                if (!Page.IsPostBack)
                {
                    PoolRotatorManager.TryAddLinkView(refUsername);
                }

                // With referral link for Pool Rotator
                refUsername = PoolRotatorManager.TryGetUserNameFromPool(refUsername);

                Referer.Text = refUsername;
            }
            else if (Session["PaidToPromoteReferer"] != null)
            {
                var refId       = Convert.ToInt32(Session["PaidToPromoteReferer"].ToString());
                var refUsername = new Member(refId).Name;

                Referer.Text = refUsername;
            }
        }
        FeatureManager Manager = null;

        //Facebook OAuth
        if (IsFromFacebookOAuth)
        {
            //Check if country is eligible for Facebook Register
            Manager = new FeatureManager(GeolocatedFeatureType.FacebookRegistration);

            //Hide unnecessary fields
            FacebookMember fbMember = new FacebookMember(Session["accessToken"].ToString());

            Email.Text = fbMember.Email;

            //Passwords validators
            RegularExpressionValidator2.Enabled = false;
            PasswordRequired.Enabled            = false;
            ConfirmPasswordRequired.Enabled     = false;
            PasswordCompare.Enabled             = false;
            CustomValidator1.Enabled            = false;
            TitanCaptcha.Visible = false;

            FirstName.Text  = fbMember.FirstName;
            SecondName.Text = fbMember.LastName;
        }
        else
        {
            //Check if country is eligible for Standard Register
            Manager = new FeatureManager(GeolocatedFeatureType.Registration);
        }

        if (!Manager.IsAllowed)
        {
            RegistrationPanel.Visible = false;
            CreateUserButton.Visible  = false;
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = U4000.SORRYCOUNTRY;
        }

        //Set up textbox hints
        HintAdder.Add(Username, L1.REG_USERNAME);
        HintAdder.Add(Password, U3501.REG_PASSWORD);
        HintAdder.Add(Email, L1.REG_EMAIL);
        HintAdder.Add(PIN, L1.REG_PIN);
        HintAdder.Add(Referer, L1.REG_REFERER);

        Username.Attributes.Add("placeholder", L1.USERNAME);
        Email.Attributes.Add("placeholder", "Email");
        Password.Attributes.Add("placeholder", L1.PASSWORD);
        ConfirmPassword.Attributes.Add("placeholder", L1.CONFIRMPASSWORD);
        PIN.Attributes.Add("placeholder", L1.DESIREDPIN);
        BirthYear.Attributes.Add("placeholder", L1.BIRTHYEAR);
        FirstName.Attributes.Add("placeholder", L1.FIRSTNAME);
        SecondName.Attributes.Add("placeholder", L1.SECONDNAME);
        City.Attributes.Add("placeholder", L1.CITY);
        StateProvince.Attributes.Add("placeholder", L1.STATEPROVINCE);
        ZipCode.Attributes.Add("placeholder", L1.ZIPCODE);

        Address.Attributes.Add("placeholder", L1.ADDRESS);

        //Add translations
        LangAdder.Add(CreateUserButton, L1.REGISTER);
        LangAdder.Add(RegularExpressionValidator1, L1.ER_INVALIDUSERNAME, true);
        LangAdder.Add(UserNameRequired, L1.REG_REQ_USERNAME, true);
        LangAdder.Add(EmailRequired, L1.REG_REQ_EMAIL, true);
        LangAdder.Add(CorrectEmailRequired, L1.ER_BADEMAILFORMAT, true);
        LangAdder.Add(PasswordRequired, L1.REG_REQ_PASS, true);
        LangAdder.Add(RegularExpressionValidator2, L1.ER_INVALIDPASS, true);
        LangAdder.Add(PasswordCompare, L1.ER_PASSDIFFER, true);
        LangAdder.Add(ConfirmPasswordRequired, L1.REG_REQ_CONFIRM, true);
        LangAdder.Add(RegularExpressionValidator3, L1.ER_BADPIN, true);
        LangAdder.Add(RequiredFieldValidator2, L1.REG_REQ_PIN, true);
        LangAdder.Add(RegularExpressionValidator4, L1.ER_BADYEAR, true);
        LangAdder.Add(RequiredFieldValidator1, L1.REG_REQ_YEAR, true);
        LangAdder.Add(RefererValidator, L1.ER_BADREF, true);
        LangAdder.Add(CustomValidator1, L1.ER_BADCAPTCHA, true);
        LangAdder.Add(CustomValidator4, L1.REG_REQ_TOS, true);

        EarnerCheckBox.Text     = U6000.EARNER;
        AdvertiserCheckBox.Text = L1.ADVERTISER;
        PublisherCheckBox.Text  = U6000.PUBLISHER;

        //Detailed info
        LangAdder.Add(RE_1, L1.DETAILEDNOSPECIAL + " " + L1.FIRSTNAME, true);
        LangAdder.Add(RF_1, L1.FIRSTNAME + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_2, L1.DETAILEDNOSPECIAL + " " + L1.SECONDNAME, true);
        LangAdder.Add(RF_2, L1.SECONDNAME + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_3, L1.DETAILEDNOSPECIAL + " " + L1.ADDRESS, true);
        LangAdder.Add(RF_3, L1.ADDRESS + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_4, L1.DETAILEDNOSPECIAL + " " + L1.CITY, true);
        LangAdder.Add(RF_4, L1.CITY + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_5, L1.DETAILEDNOSPECIAL + " " + L1.STATEPROVINCE, true);
        LangAdder.Add(RF_5, L1.STATEPROVINCE + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_6, L1.DETAILEDNOSPECIAL + " " + L1.ZIPCODE, true);
        LangAdder.Add(RF_6, L1.ZIPCODE + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(AccountTypeValidator, U6000.SELECTACCOUNTTYPE, true);

        //Check detailed info
        if (AppSettings.Authentication.DetailedRegisterFields)
        {
            DetailedPanel.Visible = true;
        }

        AvailableRolesPlaceHolder.Visible     = !AppSettings.Registration.IsDefaultRegistrationStatusEnabled;
        EarnerCheckBoxPlaceHolder.Visible     = AppSettings.TitanFeatures.EarnersRoleEnabled;
        AdvertiserCheckBoxPlaceHolder.Visible = AppSettings.TitanFeatures.AdvertisersRoleEnabled;
        PublisherCheckBoxPlaceHolder.Visible  = AppSettings.TitanFeatures.PublishersRoleEnabled;

        if (AppSettings.Registration.IsDefaultRegistrationStatusEnabled)
        {
            EarnerCheckBox.Checked     = AppSettings.Registration.IsDefaultEarnerStatus;
            AdvertiserCheckBox.Checked = AppSettings.Registration.IsDefaultAdvertiserStatus;
            PublisherCheckBox.Checked  = AppSettings.Registration.IsDefaultPublisherStatus;
        }

        //Custom field
        CustomFields.Controls.Add(RegistrationFieldCreator.Generate());

        CountryInformation CIService = new CountryInformation(IP.Current);

        CountryName.Text = CIService.CountryName;
        Flag.ImageUrl    = "~/Images/Flags/" + CIService.CountryCode.ToLower() + ".png";
    }