Esempio n. 1
0
        /* Kollar så det gamla lösenordet stämmer. */
        public bool isOldPasswordCorrect(string oldpw, User user)
        {
            if (String.IsNullOrEmpty(oldpw))
                return false;

            string hasholdpw = DevOne.Security.Cryptography.BCrypt.BCryptHelper.HashPassword(oldpw, user.Salt);

            if (hasholdpw.Equals(user.Password))
                return true;

            return false;
        }
Esempio n. 2
0
 /* Kollar om den inloggades username stämmer överens med User modellen. */
 public bool isCorrectUser(string username, User user)
 {
     if(user.UserName.Equals(username)){return true;} return false;
 }
Esempio n. 3
0
        public override MembershipUser CreateUser(string username, string password,
               string email, string passwordQuestion, string passwordAnswer,
               bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            ValidatePasswordEventArgs args =
               new ValidatePasswordEventArgs(username, password, true);
            OnValidatingPassword(args);

            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            if (RequiresUniqueEmail && GetUserNameByEmail(email) != string.Empty)
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            MembershipUser user = GetUser(username, true);

            if (user == null)
            {
                User appUser = new User();
                appUser.UserName = username;
                appUser.IsConfirmed = false;
                appUser.Salt = DevOne.Security.Cryptography.BCrypt.BCryptHelper.GenerateSalt();
                appUser.BirthDate = DateTime.Now;
                appUser.Email = "*****@*****.**";
                appUser.ID = Guid.NewGuid();

                appUser.Password = GetBcryptHash(password, appUser.Salt);
                appUser.Email = email;
                IAppUserRepository userRepo = new AppUserRepository();
                userRepo.Add(appUser);
                status = MembershipCreateStatus.Success;
                return GetUser(username, true);
            }
            else
            {
                status = MembershipCreateStatus.DuplicateUserName;
            }

            return null;
        }