Exemple #1
0
        public IDataResult <User> Login(UserForLoginDto userForLoginDto)
        {
            var userToCheck = _userService.GetByMail(userForLoginDto.Email);

            if (userToCheck == null)
            {
                return(new ErrorDataResult <User>("Kullanıcı Bulunamadı"));
            }

            if (!HasingHelper.VerifyPasswordHash(userForLoginDto.Password, userToCheck.PaswordHash, userToCheck.PaswordSalt))
            {
                return(new ErrorDataResult <User>("Parola Hatası"));
            }

            return(new SuccesDataResult <User>(userToCheck, "Başarılı Giriş"));
        }
 public IResult EditProfil(User user, string password)
 {
     byte[] passwordHash, passwordSalt;
     HasingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt);
     var updatedUser = new User
     {
         Id = user.Id,
         Email = user.Email,
         FirstName = user.FirstName,
         LastName = user.LastName,
         PasswordHash = passwordHash,
         PasswordSalt = passwordSalt,
         Status = user.Status
     };
     _userDal.Update(updatedUser);
     return new SuccessResult(Messages.UserUpdated);
 }
Exemple #3
0
        public IDataResult <User> Register(UserForRegisterDto userForRegisterDto, string password)
        {
            byte[] passwordHash, passwordSalt;
            HasingHelper.CreatePasswordHash(password, out passwordHash, out passwordSalt);
            var user = new User
            {
                Email       = userForRegisterDto.Email,
                FirstName   = userForRegisterDto.FirstName,
                LastName    = userForRegisterDto.LastName,
                PaswordHash = passwordHash,
                PaswordSalt = passwordSalt,
                Status      = true
            };

            _userService.Add(user);
            return(new SuccesDataResult <User>(user, "Kayıt Oldu"));
        }