public void SetupPasswordData( )
        {
            _inMemoryTextResource = new InMemoryTextResource( );
            _serializer = new PasswordSerializer( );
            _passwordData = new XmlPasswordData( _serializer, _inMemoryTextResource );

            _passwords = new[ ] { TestPasswords.Abcd, TestPasswords.Efgh }.ToList( );
        }
 internal XmlPasswordData( PasswordSerializer serializer, ITextResource store )
 {
     if ( serializer == null )
         throw new ArgumentNullException( "serializer" );
     if ( store == null )
         throw new ArgumentNullException( "store" );
     _serializer = serializer;
     _store = store;
 }
示例#3
0
        public HttpResponseMessage UpdatePassword([FromBody] PasswordSerializer password)
        {
            try
            {
                var user = Entities.Users.SingleOrDefault(u => u.Id == CurrentIdentity.UserId.Value);

                if (user == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new ResponseMessage
                    {
                        Success = false,
                        Message = "User not found."
                    }));
                }

                if (!BCrypt.Net.BCrypt.Verify(password.Password, user.Password))
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, new ResponseMessage
                    {
                        Success = false,
                        Message = "Password does not match."
                    }));
                }
                var hashedPassword = BCrypt.Net.BCrypt.HashPassword(password.NewPassword);

                var res = Entities.UserPasswordUpdate(hashedPassword, CurrentIdentity.UserId);

                return(Request.CreateResponse(HttpStatusCode.OK, new ResponseMessage
                {
                    Success = true,
                    Message = "Your password has been updated."
                }));
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ResponseMessage
                {
                    Success = false,
                    Message = ex.Message
                }));
            }
        }
 public void SetUpSerializer( )
 {
     _serializer = new PasswordSerializer( );
     _textResource = new InMemoryTextResource( );
 }
 public void SetUpSerializer( )
 {
     _serializer = new PasswordSerializer( );
     _textResource = new InMemoryTextResource( );
     _passwords = new List<PasswordDigestDocument>( );
 }