Example #1
0
    /// <summary>
    /// The user has clicked the login button
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Member member = Member.WebMemberLogin(txtEmailLogin.Text, txtPasswordLogin.Text);

        if (txtEmailLogin.Text == string.Empty || txtPasswordLogin.Text == string.Empty || member == null)
        {
            ShowLoginError();
        }
        else
        {
            Session["Member"] = member;

            // log the login date time
            OnlineNow now = new OnlineNow();
            now.MemberID = member.MemberID;
            now.DTOnline = DateTime.Now;
            now.Save();

            Utility.AddToLoggedIn();

            if (chbRememberMe.Checked)
            {
                WriteRememberMeCookie(txtEmailLogin.Text, txtPasswordLogin.Text);
            }

            //Response.Cookies.Add(aCookie);
            errLogin.Text = string.Empty;
            Response.Redirect("feed.aspx");
        }
    }
Example #2
0
 private static void SetOnlineNow(Int32 memberId)
 {
     try
     {
         var now = new OnlineNow()
         {
             MemberID = memberId, DTOnline = DateTime.Now
         };
         now.Save();
     }
     catch { }
 }
Example #3
0
    //public static double GetDistance(Member member1, Member member2)
    //{
    //   // IPLocation ipLoc1 = IPLocation.GetIPLocationByCountry(member1.ISOCountry);
    //    //IPLocation ipLoc2 = IPLocation.GetIPLocationByCountry(member2.ISOCountry);

    //    double lon2 = (double)ipLoc2.longitude;
    //    double lon1 = (double)ipLoc1.longitude;

    //    double lat2 = (double)ipLoc2.latitude;
    //    double lat1 = (double)ipLoc1.latitude;

    //    double dlon = lon2 - lon1;
    //    double dlat = lat2 - lat1;

    //    double a = Math.Pow(Math.Sin(dlat / 2), 2) + Math.Cos(lat1) * Math.Cos(lat2) * Math.Pow(Math.Sin(dlon / 2),2);
    //    double c = 2 * Math.Asin(Math.Min(1,Math.Sqrt(a)));

    //    return RADIUS * c;
    //}

    public static void RememberMeLogin()
    {
        System.Web.SessionState.HttpSessionState Session = HttpContext.Current.Session;
        HttpRequest Request = HttpContext.Current.Request;

        // If we are already signed in
        if (Session["Member"] != null)
        {
            return;
        }

        HttpCookie aCookie = Request.Cookies["LastActivity"];

        if (aCookie == null)
        {
            return;
        }

        string autoLogin = aCookie.Values["activityHandle"];

        if (autoLogin == "1")
        {
            string login    = aCookie.Values["activityDate"];
            string password = aCookie.Values["activityTime"];

            login    = RijndaelEncryption.Decrypt(login);
            password = RijndaelEncryption.Decrypt(password);

            Member member = Member.WebMemberLogin(login, password);

            if (member != null)
            {
                Session["Member"] = member;

                OnlineNow now = new OnlineNow();
                now.MemberID = member.MemberID;
                now.DTOnline = DateTime.Now;
                now.Save();

                string PageName = HttpContext.Current.Request.Url.AbsolutePath.ToLower();

                if (PageName == "/")
                {
                    HttpContext.Current.Response.Redirect("/dashboard");
                }
            }
        }

        Utility.AddToLoggedIn();
    }
Example #4
0
    /// <summary>
    /// The user has clicked the login button
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        ResetSignupErrorMessages();

        Member member = Member.WebMemberLogin(txtEmailLogin.Text, txtPasswordLogin.Text);

        if (member == null)
        {
            errLogin.Text = "<p class='error_alert'>Invalid email or password</p>";
        }
        else if (txtEmailLogin.Text == string.Empty || txtPasswordLogin.Text == string.Empty)
        {
            errLogin.Text = "<p class='error_alert'>Invalid email or password</p>";
        }
        else
        {
            Session["Member"] = member;

            string RedirectToURL = (string)ViewState["CameFromURL"];

            if (RedirectToURL == null)
            {
                //Response.Redirect("/chat/");
                RedirectToURL = "/dashboard";
            }

            // log the login date time
            OnlineNow now = new OnlineNow();
            now.MemberID = member.MemberID;
            now.DTOnline = DateTime.Now;
            now.Save();

            Utility.AddToLoggedIn();

            // write the login cookie
            if (chbRememberMe.Checked)
            {
                WriteRememberMeCookie(txtEmailLogin.Text, txtPasswordLogin.Text);
            }

            Response.Redirect(Server.UrlDecode(RedirectToURL));
        }
    }
Example #5
0
    public void RememberMeLogin()
    {
        // If we are already signed in
        if (Session["Member"] != null)
        {
            return;
        }

        HttpCookie aCookie = Request.Cookies["LastActivity"];



        if (aCookie == null)
        {
            return;
        }

        string autoLogin = aCookie.Values["activityHandle"];

        if (autoLogin == "1")
        {
            string login    = aCookie.Values["activityDate"];
            string password = aCookie.Values["activityTime"];

            login    = RijndaelEncryption.Decrypt(login);
            password = RijndaelEncryption.Decrypt(password);

            Member memberD = Member.WebMemberLogin(login, password);

            Session["Member"] = memberD;

            OnlineNow now = new OnlineNow();
            now.MemberID = memberD.MemberID;
            now.DTOnline = DateTime.Now;
            now.Save();

            Utility.AddToLoggedIn();
        }
    }
Example #6
0
    protected void btnSignup_Click(object sender, EventArgs e)
    {
        ResetLoginErrorMessages();

        bool   SignUpOkay = true;
        Member NewMember  = new Member();

        if (txtEmail.Text == string.Empty)
        {
            SignUpOkay        = false;
            txtEmail.CssClass = "form_txt formerror";
            errTxtEmail.Text  = "<span class='formerror_msg'>Blank field</span>";
        }
        else if (!RegexPatterns.TestEmailRegex(txtEmail.Text))
        {
            SignUpOkay        = false;
            txtEmail.CssClass = "form_txt formerror";
            errTxtEmail.Text  = "<span class='formerror_msg'>Invalid field</span>";
        }
        else if (!Member.IsEmailAddressAvailable(txtEmail.Text))
        {
            SignUpOkay        = false;
            txtEmail.CssClass = "form_txt formerror";
            errTxtEmail.Text  = "<span class='formerror_msg'>Address is already registered</span>";
        }
        else
        {
            txtEmail.CssClass = "form_txt";
            errTxtEmail.Text  = string.Empty;
        }



        if (txtFirstName.Text == string.Empty)
        {
            SignUpOkay            = false;
            txtFirstName.CssClass = "form_txt formerror";
            errTxtFirstName.Text  = "<span class='formerror_msg'>Blank field</span>";
        }
        else
        {
            txtFirstName.CssClass = "form_txt";
            errTxtFirstName.Text  = string.Empty;
        }

        if (txtLastName.Text == string.Empty)
        {
            SignUpOkay           = false;
            txtLastName.CssClass = "form_txt formerror";
            errTxtLastName.Text  = "<span class='formerror_msg'>Blank field</span>";
        }
        else
        {
            txtLastName.CssClass = "form_txt";
            errTxtLastName.Text  = string.Empty;
        }


        if (!RegexPatterns.TestNickname(txtNickName.Text))
        {
            SignUpOkay           = false;
            txtNickName.CssClass = "form_txt formerror";
            errTxtNickName.Text  = "<span id='spanErrNickName' class='formerror_msg'>Incorrect format</span>";
        }
        else if (!Member.IsNicknameAvailable(txtNickName.Text))
        {
            SignUpOkay            = false;
            txtFirstName.CssClass = "form_txt formerror";
            errTxtNickName.Text   = "<span id='spanErrNickName' class='formerror_msg'>Unavailable</span>";
        }
        else
        {
            txtNickName.CssClass = "form_txt";
            errTxtNickName.Text  = string.Empty;
        }

        if (txtPassword1.Text == string.Empty)
        {
            SignUpOkay            = false;
            txtPassword1.CssClass = "form_txt formerror";
            txtPassword2.CssClass = "form_txt formerror";
            errTxtPassword1.Text  = "<span id='spanErrPassword' class='formerror_msg'>Blank field</span>";
        }
        else if (txtPassword1.Text != txtPassword2.Text)
        {
            SignUpOkay            = false;
            txtPassword1.CssClass = "form_txt formerror";
            txtPassword2.CssClass = "form_txt formerror";
            errTxtPassword1.Text  = "<span  id='spanErrPassword' class='formerror_msg'>Password do no match</span>";
        }
        else
        {
            txtPassword1.CssClass = "form_txt";
            txtPassword2.CssClass = "form_txt";
            errTxtPassword1.Text  = string.Empty;
        }

        if (drpCopuntries.SelectedIndex == 0)
        {
            SignUpOkay             = false;
            drpCopuntries.CssClass = "form_txt formerror";
            errDrpCountries.Text   = "<span class='formerror_msg'>Blank field</span>";
        }
        else
        {
            drpCopuntries.CssClass = "form_txt";
            errDrpCountries.Text   = string.Empty;
        }

        if (txtZipPostcode.Text == string.Empty)
        {
            //SignUpOkay = false;
            //txtZipPostcode.CssClass = "form_txt formerror";
            //errTxtZipPostcode.Text = "<span class='formerror_msg'>Blank zip/postcode</span>";
        }
        else
        {
            txtZipPostcode.CssClass = "form_txt";
            errTxtZipPostcode.Text  = string.Empty;
        }

        Gender MemberGender = Gender.NotSet;

        if (rbPersonal.Checked)
        {
            if (rbMale.Checked == false && rbFemale.Checked == false)
            {
                SignUpOkay        = false;
                rbMale.CssClass   = "form_txt formerror";
                rbFemale.CssClass = "form_txt formerror";
                errRblGender.Text = "<span class='formerror_msg'>Blank field</span>";
            }
            else
            {
                MemberGender      = rbFemale.Checked ? Gender.Female : Gender.Male;
                rbMale.CssClass   = "";
                rbFemale.CssClass = "";
                errRblGender.Text = string.Empty;
            }
        }

        // set to a date to avoid a compile error
        DateTime DOB = DateTime.Now;

        if (rbPersonal.Checked)
        {
            try
            {
                DOB = new DateTime(Int32.Parse(drpYear.SelectedValue),
                                   Int32.Parse(drpMonth.SelectedValue),
                                   Int32.Parse(drpDay.SelectedValue));

                drpDay.CssClass   = "form_txt";
                drpMonth.CssClass = "form_txt";
                drpYear.CssClass  = "form_txt";
                errDOB.Text       = string.Empty;
            }
            catch
            {
                SignUpOkay        = false;
                drpDay.CssClass   = "form_txt formerror";
                drpMonth.CssClass = "form_txt formerror";
                drpYear.CssClass  = "form_txt formerror";
                errDOB.Text       = "<span class='formerror_msg'>Invalid date</span>";
            }
        }

        if (rbBusiness.Checked)
        {
            if (txtCompanyName.Text == string.Empty)
            {
                SignUpOkay              = false;
                errTxtCompanyName.Text  = "<span class='formerror_msg'>Blank field</span><br/>";
                txtCompanyName.CssClass = "form_txt formerror";
            }
            else
            {
                errTxtCompanyName.Text  = string.Empty;
                txtCompanyName.CssClass = "form_txt";
            }

            if (drpIndustrySector.SelectedIndex == 0)
            {
                SignUpOkay = false;
                errTxtIndustrySector.Text  = "<span class='formerror_msg'>Blank field</span><br/>";
                drpIndustrySector.CssClass = "form_txt formerror";
            }
            else
            {
                errTxtIndustrySector.Text  = string.Empty;
                drpIndustrySector.CssClass = "form_txt";
            }

            if (drpCompanySize.SelectedIndex == 0)
            {
                SignUpOkay = false;
                errTxtNumberOfEmployees.Text = "<span class='formerror_msg'>Blank field</span><br/>";
                drpCompanySize.CssClass      = "form_txt formerror";
            }
            else
            {
                errTxtNumberOfEmployees.Text = string.Empty;
                drpCompanySize.CssClass      = "form_txt";
            }

            if (drpYearFounded.SelectedIndex == 0)
            {
                SignUpOkay              = false;
                errTxtYearFounded.Text  = "<span class='formerror_msg'>Blank field</span><br/>";
                drpYearFounded.CssClass = "form_txt formerror";
            }
            else
            {
                errTxtYearFounded.Text  = string.Empty;
                drpYearFounded.CssClass = "form_txt";
            }
        }

        string CaptchaAttempt = txtCaptcha.Text.Trim().ToUpper();

        if (SignupCaptcha.Validate(CaptchaAttempt))
        {
            // successful
            errCaptcha.Text = string.Empty;
            txtCaptcha.Text = string.Empty;
        }
        else
        {
            errCaptcha.Text = "<span class='formerror_msg'>Incorrect, please try again</span><br/>";
            SignUpOkay      = false;
            txtCaptcha.Text = string.Empty;
        }


        if (chbAgree.Checked == false)
        {
            SignUpOkay       = false;
            errChbAgree.Text = "<span class='formerror_msg'>Agree to terms and conditions</span><br/>";
        }
        else
        {
            errChbAgree.Text = string.Empty;
        }


        if (SignUpOkay)
        {
            Database      db          = DatabaseFactory.CreateDatabase();
            DbConnection  conn        = db.CreateConnection();
            DbTransaction Transaction = null;

            try
            {
                conn.Open();
                Transaction = conn.BeginTransaction();

                NewMember.Email    = txtEmail.Text;
                NewMember.NickName = txtNickName.Text;

                if (rbPersonal.Checked)
                {
                    NewMember.FirstName = txtFirstName.Text;
                    NewMember.LastName  = txtLastName.Text;
                }
                else if (rbBusiness.Checked)
                {
                    // set the company name as the first name for display purposes
                    NewMember.FirstName = txtCompanyName.Text;
                }


                NewMember.AccountType = (rbPersonal.Checked) ? 0 : 1;
                NewMember.Password    = txtPassword1.Text;
                NewMember.ISOCountry  = drpCopuntries.SelectedValue;
                NewMember.Gender      = (int)MemberGender;
                NewMember.ZipPostcode = txtZipPostcode.Text;
                NewMember.DOB         = DOB;
                NewMember.ProfilePhotoResourceFileID = 1;
                NewMember.WebMemberID = Next2Friends.Misc.UniqueID.NewWebID();
                NewMember.CreatedDT   = DateTime.Now;
                NewMember.Save(db);

                // Ceate the business Account
                if (rbBusiness.Checked)
                {
                    Business business = new Business();
                    business.MemberID       = NewMember.MemberID;
                    business.CompanyName    = txtCompanyName.Text;
                    business.IndustrySector = drpIndustrySector.SelectedValue;
                    business.YearFounded    = Int32.Parse(drpYearFounded.SelectedValue);
                    business.CompanySize    = drpCompanySize.Text;
                    business.IndustrySector = drpIndustrySector.SelectedValue;
                    business.Save(db);

                    IMSPlan imsPlan = new IMSPlan();
                    imsPlan.BusinessID = business.BusinessID;
                    imsPlan.Save(db);
                }


                //ResourceFile.CreateUserDirectories(NewMember);
                TEMPCreateUserDirectories(NewMember);

                PhotoCollection DefaultGallery = new PhotoCollection();
                DefaultGallery.WebPhotoCollectionID = Next2Friends.Misc.UniqueID.NewWebID();
                DefaultGallery.MemberID             = NewMember.MemberID;
                DefaultGallery.DTCreated            = DateTime.Now;
                DefaultGallery.Name        = NewMember.NickName + "'s Gallery";
                DefaultGallery.Description = "My First Gallery!";
                DefaultGallery.Save(db);

                string StatusText = "New to next2Friends!";

                // create a new member profile for the meber
                Next2Friends.Data.MemberProfile profile = new Next2Friends.Data.MemberProfile();
                profile.MemberID                 = NewMember.MemberID;
                profile.HomeTown                 = txtCity.Text;
                profile.DTLastUpdated            = DateTime.Now;
                profile.DefaultPhotoCollectionID = DefaultGallery.PhotoCollectionID;
                profile.TagLine = StatusText;
                profile.Save(db);

                MemberStatusText.UpdateStatusText(NewMember.MemberID, StatusText);

                Message message = new Message();
                message.Body         = "Welcome to Next2Friends";
                message.WebMessageID = Next2Friends.Misc.UniqueID.NewWebID();
                message.MemberIDFrom = 31;
                message.MemberIDTo   = NewMember.MemberID;
                message.DTCreated    = DateTime.Now;
                message.Save(db);
                message.InReplyToID = message.MessageID;
                message.Save(db);

                // create the default settings for the member
                MemberSettings settings = new MemberSettings();

                settings.NotifyNewPhotoComment   = true;
                settings.NotifyNewProfileComment = true;
                settings.NotifyNewVideoComment   = true;
                settings.NotifyOnAAFComment      = true;
                settings.NotifyOnFriendRequest   = true;
                settings.NotifyOnNewMessage      = true;
                settings.NotifyOnNewsLetter      = true;
                settings.NotifyOnSubscriberEvent = true;

                settings.MemberID = NewMember.MemberID;
                settings.Save(db);

                MatchProfile matchProfile = new MatchProfile();
                matchProfile.MemberID = NewMember.MemberID;
                matchProfile.Save(db);

                Device Device = new Device();
                Device.MemberID             = NewMember.MemberID;
                Device.PrivateEncryptionKey = Next2Friends.Misc.UniqueID.NewEncryptionKey();
                Device.CreatedDT            = DateTime.Now;
                Device.DeviceTagID          = Guid.NewGuid().ToString();
                Device.Save(db);

                OnlineNow now = new OnlineNow();
                now.MemberID = NewMember.MemberID;
                now.DTOnline = DateTime.Now;
                now.Save(db);

                Session["Member"] = NewMember;
                Transaction.Commit();

                Utility.AddToLoggedIn();

                EmailReferral emailReferral = new EmailReferral();
                emailReferral.Email       = txtReferralEmail.Text;
                emailReferral.NewMemberID = NewMember.MemberID;
                emailReferral.DTCreated   = DateTime.Now;
                emailReferral.Save();

                // this denotes that the user landed on the site from a referral
                int ReferralContactID = Referral.ProcessSignupFromReferral(this.Context, NewMember.MemberID);

                // search the contact import table for any users that have files a friend request
                FriendRequest.CreateFriendRequestsFromImport(NewMember, ReferralContactID);

                try
                {
                    // Add Lawrence as Auto Friend
                    Friend.AddFriend(1, NewMember.MemberID);
                    // Add Anthony as Auto Friend
                    Friend.AddFriend(3, NewMember.MemberID);
                    // Add Hans as Auto Friend
                    Friend.AddFriend(24, NewMember.MemberID);
                    // Add Becca as Auto Friend
                    Friend.AddFriend(30, NewMember.MemberID);

                    Utility.ContentViewed(new Member(1), NewMember.MemberID, CommentType.Member);
                    Utility.ContentViewed(new Member(3), NewMember.MemberID, CommentType.Member);
                    Utility.ContentViewed(new Member(24), NewMember.MemberID, CommentType.Member);
                    Utility.ContentViewed(new Member(30), NewMember.MemberID, CommentType.Member);
                }
                catch { }
            }
            catch (Exception ex)
            {
                Transaction.Rollback();
                throw ex;
            }
            finally
            {
                conn.Close();

                Session["SignedUp"] = true;

                // send the member to the second page of signup
                Response.Redirect("/settings/?signup=true");
            }
        }
    }
Example #7
0
    protected void btnSignup2_Click(object sender, EventArgs e)
    {
        bool SignUpOkay = true;

        if (txtFirstName.Text.Trim() == string.Empty)
        {
            SignUpOkay           = false;
            errTxtFirstName.Text = "<span class='formerror_msg'>No first name</span>";
        }
        else
        {
            errTxtFirstName.Text = string.Empty;
        }

        if (txtLastName.Text.Trim() == string.Empty)
        {
            SignUpOkay          = false;
            errTxtLastName.Text = "<span class='formerror_msg'>No last name</span>";
        }
        else
        {
            errTxtLastName.Text = string.Empty;
        }

        if (txtPassword.Text == string.Empty)
        {
            SignUpOkay          = false;
            errTxtPassword.Text = "<span class='formerror_msg'>No password</span>";
        }
        else if (txtPassword.Text != txtConfirm.Text)
        {
            SignUpOkay          = false;
            errTxtPassword.Text = "<span class='formerror_msg'>Passwords do no match</span>";
        }
        else if (!RegexPatterns.TestPassword(txtPassword.Text))
        {
            SignUpOkay          = false;
            errTxtPassword.Text = "minimum length 7 characters";
        }
        else
        {
            errTxtPassword.Text = string.Empty;
        }

        if (!cbTOS.Checked)
        {
            SignUpOkay     = false;
            errChbTOS.Text = "<span class='formerror_msg'>You must agree to the tos</span>";
        }
        else
        {
            errChbTOS.Text = string.Empty;
        }

        if (SignUpOkay)
        {
            NewMember = (Member)Session["Member"];

            CurrentStage = MobileSignupStage.Complete;

            Database      db          = DatabaseFactory.CreateDatabase();
            DbConnection  conn        = db.CreateConnection();
            DbTransaction Transaction = null;

            try
            {
                conn.Open();
                Transaction = conn.BeginTransaction();

                NewMember.FirstName = txtFirstName.Text;
                NewMember.LastName  = txtLastName.Text;


                NewMember.AccountType = 0;
                NewMember.Password    = txtPassword.Text;

                NewMember.ProfilePhotoResourceFileID = 1;
                NewMember.WebMemberID = Next2Friends.Misc.UniqueID.NewWebID();
                NewMember.CreatedDT   = DateTime.Now;
                NewMember.Save(db);

                // Ceate the business Account
                //if (rbBusiness.Checked)
                //{
                //    Business business = new Business();
                //    business.MemberID = NewMember.MemberID;
                //    business.CompanyName = txtCompanyName.Text;
                //    business.IndustrySector = drpIndustrySector.SelectedValue;
                //    business.YearFounded = Int32.Parse(drpYearFounded.SelectedValue);
                //    business.CompanySize = drpCompanySize.Text;
                //    business.IndustrySector = drpIndustrySector.SelectedValue;
                //    business.Save(db);

                //    IMSPlan imsPlan = new IMSPlan();
                //    imsPlan.BusinessID = business.BusinessID;
                //    imsPlan.Save(db);
                //}


                //ResourceFile.CreateUserDirectories(NewMember);
                TEMPCreateUserDirectories(NewMember);

                PhotoCollection DefaultGallery = new PhotoCollection();
                DefaultGallery.WebPhotoCollectionID = Next2Friends.Misc.UniqueID.NewWebID();
                DefaultGallery.MemberID             = NewMember.MemberID;
                DefaultGallery.DTCreated            = DateTime.Now;
                DefaultGallery.Name        = NewMember.NickName + "'s Gallery";
                DefaultGallery.Description = "My First Gallery!";
                DefaultGallery.Save(db);

                // create a new member profile for the meber
                Next2Friends.Data.MemberProfile profile = new Next2Friends.Data.MemberProfile();
                profile.MemberID                 = NewMember.MemberID;
                profile.DTLastUpdated            = DateTime.Now;
                profile.DefaultPhotoCollectionID = DefaultGallery.PhotoCollectionID;
                profile.Save(db);

                Message message = new Message();
                message.Body         = "Welcome to Next2Friends";
                message.WebMessageID = Next2Friends.Misc.UniqueID.NewWebID();
                message.MemberIDFrom = 31;
                message.MemberIDTo   = NewMember.MemberID;
                message.DTCreated    = DateTime.Now;
                message.Save(db);
                message.InReplyToID = message.MessageID;
                message.Save(db);

                // create the default settings for the member
                MemberSettings settings = new MemberSettings();

                settings.NotifyNewPhotoComment   = true;
                settings.NotifyNewProfileComment = true;
                settings.NotifyNewVideoComment   = true;
                settings.NotifyOnAAFComment      = true;
                settings.NotifyOnFriendRequest   = true;
                settings.NotifyOnNewMessage      = true;
                settings.NotifyOnNewsLetter      = true;
                settings.NotifyOnSubscriberEvent = true;

                settings.MemberID = NewMember.MemberID;
                settings.Save(db);

                MatchProfile matchProfile = new MatchProfile();
                matchProfile.MemberID = NewMember.MemberID;
                matchProfile.Save(db);

                Device Device = new Device();
                Device.MemberID             = NewMember.MemberID;
                Device.PrivateEncryptionKey = Next2Friends.Misc.UniqueID.NewEncryptionKey();
                Device.CreatedDT            = DateTime.Now;
                Device.DeviceTagID          = Guid.NewGuid().ToString();
                Device.Save(db);

                OnlineNow now = new OnlineNow();
                now.MemberID = NewMember.MemberID;
                now.DTOnline = DateTime.Now;
                now.Save(db);

                Session["Member"] = NewMember;
                Transaction.Commit();

                Utility.AddToLoggedIn();
            }
            catch (Exception ex)
            {
                Transaction.Rollback();
                throw ex;
            }
            finally
            {
                conn.Close();
            }
        }
        else
        {
            CurrentStage = MobileSignupStage.Stage2;
        }
    }
Example #8
0
    /// <summary>
    /// The user has clicked the login button
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Member member = Member.WebMemberLogin(txtEmailLogin.Text, txtPassword.Text);

        if (member == null)
        {
            // for the user to the login page and show the message
            string url = "/signup/?err=true";
            if (ViewState["CameFromURL"] != null)
            {
                url += "&u=" + ViewState["CameFromURL"];
            }

            Response.Redirect(url);
        }
        else if (txtEmailLogin.Text == string.Empty || txtPassword.Text == string.Empty)
        {
            // for the user to the login page and show the message
            string url = "/signup/?err=true";
            if (ViewState["CameFromURL"] != null)
            {
                url += "&u=" + ViewState["CameFromURL"];
            }

            Response.Redirect(url);
        }
        else
        {
            Session["Member"] = member;

            string RedirectToURL = (string)ViewState["CameFromURL"];

            if (RedirectToURL == null)
            {
                //Response.Redirect("/chat/");
                RedirectToURL = "/dashboard";
            }


            //HttpCookie aCookie = new HttpCookie("userInfo");
            //aCookie.Values["email"] = member.Email;
            //aCookie.Values["password"] = member.Password;

            // log the login date time
            OnlineNow now = new OnlineNow();
            now.MemberID = member.MemberID;
            now.DTOnline = DateTime.Now;
            now.Save();

            Utility.AddToLoggedIn();

            if (chbRememberMe.Checked)
            {
                WriteRememberMeCookie(txtEmailLogin.Text, txtPassword.Text);
            }

            Response.Redirect(RedirectToURL);
            //Response.Redirect("index.aspx");
            //Response.Redirect("/chat/");
        }
    }