예제 #1
0
파일: UserRepository.cs 프로젝트: soks/RSS
        public bool ActivateUser(string username, string key)
        {
            using (RssFeedDBConnection db = new RssFeedDBConnection())
            {
                var result = from u in db.Users where (u.UserName == username) select u;

                if (result.Count() != 0)
                {
                    var dbuser = result.First();

                    if (dbuser.NewEmailKey == key)
                    {
                        dbuser.IsActivated = true;
                        dbuser.LastModifiedDate = DateTime.Now;
                        dbuser.NewEmailKey = null;

                        db.SaveChanges();

                        return true;
                    }
                    else
                    {
                        return false;
                    }

                }
                else
                {
                    return false;
                }
            }
        }
예제 #2
0
파일: User.cs 프로젝트: soks/RSS
 public static User GetUserByID(Guid ID)
 {
     RssFeedDBConnection db = new RssFeedDBConnection();
     User user = new User();
     user = db.Users.SingleOrDefault(u => u.ID == ID);
     return user;
 }
예제 #3
0
파일: User.cs 프로젝트: soks/RSS
 public static Guid GetIDByName(string Name)
 {
     RssFeedDBConnection db = new RssFeedDBConnection();
     Guid ID;
     User user = db.Users.SingleOrDefault(u => u.UserName == Name);
     ID = user.ID;
     return ID;
 }
예제 #4
0
파일: UserRepository.cs 프로젝트: soks/RSS
 public MembershipUser GetUser(string username)
 {
     using (RssFeedDBConnection db = new RssFeedDBConnection())
     {
         var result = from u in db.Users where (u.UserName == username) select u;
         if (result.Count() != 0)
         {
             var dbuser = result.FirstOrDefault();
             string _username = dbuser.UserName;
             Guid _providerUserKey = dbuser.ID;
             string _email = dbuser.Email;
             string _passwordQuestion = "";
             string _comment = dbuser.Comments;
             bool _isApproved = dbuser.IsActivated;
             bool _isLockedOut = dbuser.IsLockedOut;
             DateTime _creationDate = dbuser.CreatedDate;
             DateTime _lastLoginDate = dbuser.LastLoginDate;
             DateTime _lastActivityDate = DateTime.Now;
             DateTime _lastPasswordChangedDate = DateTime.Now;
             DateTime _lastLockedOutDate = dbuser.LastLockedOutDate;
             MembershipUser user = new MembershipUser("CustomMembershipProvider",
                                                     _username,
                                                     _providerUserKey,
                                                     _email,
                                                     _passwordQuestion,
                                                     _comment,
                                                     _isApproved,
                                                     _isLockedOut,
                                                     _creationDate,
                                                     _lastLoginDate,
                                                     _lastActivityDate,
                                                     _lastPasswordChangedDate,
                                                     _lastLockedOutDate);
             return user;
         }
         else
         {
             return null;
         }
     }
 }
예제 #5
0
파일: UserRepository.cs 프로젝트: soks/RSS
        public MembershipUser CreateUser(string username, string password, string email)
        {
            using (RssFeedDBConnection db = new RssFeedDBConnection())
            {
                User user = new User();
                user.ID = Guid.NewGuid();
                user.UserName = username;
                user.Email = email;
                user.PasswordSolt = CreateSalt();
                user.Password = CreatePasswordHash(password, user.PasswordSolt);
                user.CreatedDate = DateTime.Now;
                user.IsActivated = false;
                user.IsLockedOut = false;
                user.LastLockedOutDate = DateTime.Now;
                user.LastLoginDate = DateTime.Now;
                user.NewEmailKey = GenerateKey();
                db.AddToUsers(user);
                db.SaveChanges();
                SendEmailKey(user);

                return GetUser(username);
            }
        }
예제 #6
0
파일: UserRepository.cs 프로젝트: soks/RSS
        public bool ValidateUser(string username, string password)
        {
            using (RssFeedDBConnection db = new RssFeedDBConnection())
            {
                var result = from u in db.Users where (u.UserName == username) select u;

                if (result.Count() != 0)
                {
                    var dbuser = result.First();

                    if (dbuser.Password == CreatePasswordHash(password, dbuser.PasswordSolt) &&
                                                                        dbuser.IsActivated == true)
                        return true;
                    else
                        return false;
                }
                else
                {
                    return false;
                }
            }
        }
예제 #7
0
파일: UserRepository.cs 프로젝트: soks/RSS
 public string GetUserNameByEmail(string email)
 {
     using (RssFeedDBConnection db = new RssFeedDBConnection())
     {
         var result = from u in db.Users where (u.Email == email) select u;
         if (result.Count() != 0)
         {
             var dbuser = result.FirstOrDefault();
             return dbuser.UserName;
         }
         else
         {
             return "";
         }
     }
 }
예제 #8
0
파일: User.cs 프로젝트: soks/RSS
 public static User GetUserByName(string Name)
 {
     RssFeedDBConnection db = new RssFeedDBConnection();
     User user = db.Users.SingleOrDefault(u => u.UserName == Name);
     return user;
 }