input: Write a python function to handle user registration and login using Flask and Flask-RESTful.
  assert UserRegister().post() == {'msg': 'User registered successfully!'}
  assert UserLogin().post() == {'msg': 'User logged in successfully!'}
output: from flask import Flask, request
  from flask_restful import Resource, Api
  from werkzeug.security import generate_password_hash, check_password_hash
  
  app = Flask(__name__)
  api = Api(app)
  
  # In-memory storage for demonstration purposes
  users = {}
  
  class UserRegister(Resource):
      def post(self):
          data = request.get_json()
          username = data['username']
          password = data['password']
  
          if username in users:
              return {'msg': 'User already exists!'}, 400
  
          hashed_password = generate_password_hash(password)
          users[username] = hashed_password
          return {'msg': 'User registered successfully!'}
  
  class UserLogin(Resource):
      def post(self):
          data = request.get_json()
          username = data['username']
          password = data['password']
  
          if username not in users:
              return {'msg': 'User not found!'}, 404
  
          if not check_password_hash(users[username], password):
              return {'msg': 'Invalid password!'}, 401
  
          return {'msg': 'User logged in successfully!'}
  
  api.add_resource(UserRegister, '/register')
  api.add_resource(UserLogin, '/login')
  
  if __name__ == '__main__':
      app.run(debug=True)