from .models import User, decrypt
from rest_framework import serializers


class UserSerializer(serializers.HyperlinkedModelSerializer):
    tunnel_user = serializers.SerializerMethodField()
    tunnel_password = serializers.SerializerMethodField()

    class Meta:
        model = User
        fields = ('tunnel_user', 'tunnel_password')

    def get_tunnel_user(self, obj):
        return decrypt(obj.tunnel_user)

    def get_tunnel_password(self, obj):
        return decrypt(obj.tunnel_password)
