示例#1
0
        public IEnumerable <Site> FindUserSites()
        {
            string      userID = this.user.ToString();
            List <Site> list   = new List <Site>();

            foreach (var item in db.Entity <UserSite>().Query().Where(m => m.UserID == userID).ToList())
            {
                list.AddRange(db.Entity <Site>().Query().Where(m => m.Id == item.SiteID).ToList());
            }
            return(list);
        }
示例#2
0
 public UserEmail VerifyEmail(string email)
 {
     return(db.Entity <UserEmail>().Query().Where(m => m.Email == email).FirstOrDefault());
 }
示例#3
0
        private Result <UserProfile> MobileLogin(string phoneNumber, string password, string code)
        {
            var  userPhone = db.Entity <UserPhone>().Query().Where(m => m.PhoneNumber == phoneNumber).FirstOrDefault();
            User user;

            if (userPhone == null)
            {
                var userId = Guid.NewGuid().ToString("N");
                user = new User()
                {
                    Id              = userId,
                    Province        = string.Empty,
                    Birthday        = string.Empty,
                    City            = string.Empty,
                    Country         = string.Empty,
                    Distinct        = string.Empty,
                    Name            = phoneNumber,
                    NickName        = phoneNumber,
                    Gender          = GenderType.Unkonw,
                    IsConfirmed     = false,
                    Grade           = GradeType.Crystal,
                    IsLocked        = false,
                    IsLunarBirthday = false,
                    LockedTime      = null,
                    UserName        = phoneNumber,
                    Password        = Cryptor.EncryptMD5(password),
                    Roles           = string.Empty,
                };
                userPhone = new UserPhone()
                {
                    ValidateTime = DateTime.UtcNow,
                    UserID       = userId,
                    PhoneNumber  = phoneNumber,
                    Type         = PhoneType.MobilePhone,
                    IsConfirmed  = false,
                    ValidateCode = ValidateCodeGenerator.CreateRandomCode(6),
                };


                db.Entity <User>().Insert(user);
                db.Entity <UserPhone>().Insert(userPhone);

                return(Result <UserProfile> .Success(new UserProfile()
                {
                    Id = user.Id,
                    Language = user.Language,
                    Birthday = user.Birthday,
                    City = user.City,
                    Country = user.Country,
                    Distinct = user.Distinct,
                    Gender = user.Gender,
                    IsConfirmed = user.IsConfirmed,
                    IsLocked = user.IsLocked,
                    IsLunarBirthday = user.IsLunarBirthday,
                    LockedTime = user.LockedTime,
                    Name = user.Name,
                    NickName = user.NickName,
                    Province = user.Province,
                    UserName = user.UserName,
                    Roles = user.Roles.Split(';', ',', '|'),
                }));
            }
            user = db.Entity <User>().Query().Where(m => m.Id == userPhone.UserID && !m.IsLocked).FirstOrDefault();
            if (user == null)
            {
                return(Result <UserProfile> .Fail(ResultCode.Error));
            }
            if (Cryptor.EncryptMD5(password) == user.Password)
            {
                return(Result <UserProfile> .Success(new UserProfile()
                {
                    Id = user.Id,
                    Language = user.Language,
                    Birthday = user.Birthday,
                    City = user.City,
                    Country = user.Country,
                    Distinct = user.Distinct,
                    Gender = user.Gender,
                    IsConfirmed = user.IsConfirmed,
                    IsLocked = user.IsLocked,
                    IsLunarBirthday = user.IsLunarBirthday,
                    LockedTime = user.LockedTime,
                    Name = user.Name,
                    NickName = user.NickName,
                    Province = user.Province,
                    UserName = user.UserName,
                    Roles = user.Roles.Split(';', ',', '|'),
                }));
            }
            return(Result <UserProfile> .Fail(ResultCode.Error));
        }