예제 #1
0
        public bool DeleteUser(string email)
        {
            var usr = profileRepo.GetProfileByEmail(email);

            //-- Delete CF4 Profile
            if (usr != default(Profile))
            {
                if (CfIdentity.UserID != usr.ID && !CfPrincipal.IsGod())
                {
                    throw new AccessViolationException("Cannot delete a profile that does not belong to you.");
                }
                DeleteCfProfileAndRelatedData(usr);
            }

            //-- Delete CF3 Profile
            var cf3Profile = new cf.DataAccess.cf3.ClimberProfileDA().GetClimberProfile(email);

            if (cf3Profile != default(Cf3Profile))
            {
                new cf.DataAccess.cf3.ClimberProfileDA().DeleteUserCompletely(cf3Profile.ID);
            }

            //-- Delete Membership User
            var mUser = Membership.GetUser(email);

            if (mUser != default(MembershipUser))
            {
                Membership.DeleteUser(email);
            }

            return(true);
        }
예제 #2
0
        public bool ChangeUserEmail(string oldemail, string newemail)
        {
            var success = false;

            success = new cf.DataAccess.cf3.ClimberProfileDA().UpdateEmail(oldemail, newemail);
            if (success)
            {
                var cf4profile = profileRepo.GetProfileByEmail(oldemail);
                cf4profile.Email = newemail;
                profileRepo.Update(cf4profile);
            }
            return(success);
        }
예제 #3
0
        /// <summary>
        /// Used:
        /// 1) In the case when the facebook ID does not match a profile, but the user is signed in to facebook (we check if we can connect the accounts)
        /// 2) When the user logs in with their CF3 email/password to a client (Accounts Server, PG Site, CF4, Mobile App) for the first time
        /// </summary>
        public Profile GetUserByEmailAndCreateCf4ProfileIfNotExists(string email)
        {
            var profile = profileRepo.GetProfileByEmail(email);

            if (profile == null)
            {
                var cf3Profile = new cf.DataAccess.cf3.ClimberProfileDA().GetClimberProfile(email);
                if (cf3Profile != default(Cf3Profile))
                {
                    var    idStr    = cf3Profile.ID.ToString();
                    string userName = idStr.Substring(idStr.Length - 9, 8);

                    profile = new Profile()
                    {
                        ID                           = cf3Profile.ID,
                        CountryID                    = byte.Parse(cf3Profile.Nationality.ToString()),
                        DisplayNameTypeID            = 0,
                        Email                        = email,
                        FullName                     = cf3Profile.FullName,
                        IsMale                       = cf3Profile.IsMale.Value,
                        NickName                     = cf3Profile.NickName,
                        UserName                     = userName,
                        ContactNumber                = cf3Profile.ContractPhoneNumber,
                        PrivacyAllowNewConversations = true,
                        PrivacyShowFeed              = true,
                        PrivacyShowHistory           = true,
                        PrivacyPostsDefaultIsPublic  = true,
                        PrivacyShowInSearch          = true,
                        PrivacyShowOnPartnerSites    = true
                    };

                    profileRepo.Create(profile);

                    var traceMsg = string.Format("{0} upgraded cf3 account", cf3Profile.FullName);
                    CfTrace.Information(TraceCode.UserCreateAccount, traceMsg);
                    MailMan.SendAppEvent(TraceCode.UserCreateAccount, traceMsg, email, cf3Profile.ID, "*****@*****.**", true);

                    try
                    {
                        var originalImgUrl = GetCf3ProfilePicFullSizeUrl(cf3Profile.ID, cf3Profile.ProfilePictureFile);
                        if (!string.IsNullOrWhiteSpace(originalImgUrl))
                        {
                            using (Stream imgStream = new ImageDownloader().DownloadImageAsStream(originalImgUrl))
                            {
                                if (imgStream == null)
                                {
                                    throw new ArgumentException("Cf3 image stream is null for: " + originalImgUrl);
                                }
                                if (profile == null)
                                {
                                    throw new ArgumentException("Profile is null...");
                                }

                                //-- Note this function automatically updates the user object in the database
                                SaveProfileAvatarPicFrom3rdPartSource(imgStream, profile);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        CfTrace.Error(ex);
                    }
                }
            }

            return(profile);
        }